Main Content

quit

Terminate MATLAB program

Description

quit terminates the MATLAB® program. The quit function does not automatically save the workspace.

To interrupt a MATLAB command, see Stop Execution.

quit cancel is for use in a finish.m script and cancels quitting. It has no effect anywhere else.

quit force bypasses finish.m and terminates MATLAB. Use this syntax to override the finish script if the script does not let you quit.

quit(code) returns the specified value as the MATLAB exit code.

quit(code,"force") bypasses finish.m and terminates MATLAB with the exit code.

Example: quit(0,"force")

Input Arguments

collapse all

Exit code, specified as a signed integer. On Windows® platforms, MATLAB returns values in the range of INT_MIN to INT_MAX (-2147483647 to 2147483647). On Linux® and macOS platforms,​ MATLAB returns values between 0 and 255.

The exit code is returned by default on macOS and Linux. On Windows, start MATLAB with the -wait option.

Example: quit(1)

Alternatives

Click the close button on the MATLAB desktop.

Version History

Introduced before R2006a

See Also

| |