Method

# Quit

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Quits the application.

## Usage

``` xojo
Quit([ status ])
```

| Part   | Type                               | Description                                                                  |
|--------|------------------------------------|------------------------------------------------------------------------------|
| status | `Integer</api/data_types/integer>` | For console applications only, the optional parameter returns a status code. |

## Notes

Calling the <span class="title-ref">Quit</span> method will call the `DesktopApplication</api/user_interface/desktop/desktopapplication>` class's `CancelClosing<desktopapplication.cancelclosing>` event. To cancel the close, return `True</api/language/true>` from this event. If it does not return `True</api/language/true>`, each window's `CancelClosing<desktopwindow.cancelclosing>` event handler is called. CancelClosing and Close are called as a pair for each open window.

If a `CancelClosing<desktopwindow.cancelclosing>` event handler returns `False</api/language/false>` (the default action) then the window's `Closing<desktopwindow.closing>` event handler is called. If any window's `CancelClosing<desktopwindow.cancelclosing>` event handler returns `True</api/language/true>`, the app will not <span class="title-ref">Quit</span> and no further CancelClosing or Closing events will be called.

An `EndException</api/exceptions/endexception>` is raised when you call <span class="title-ref">Quit</span>. It causes the app to <span class="title-ref">Quit</span> gracefully. Usually you do not see the `EndException</api/exceptions/endexception>` unless you use a catch-all `Exception</api/exceptions/exception>` statement.

If you just need to have your app <span class="title-ref">Quit</span> when last window is closed, you can use the `DesktopApplication.AllowAutoQuit<desktopapplication.allowautoquit>` property.

## Sample code

This example quits the application.

``` xojo
Quit
```

## Compatibility

|                       |                       |
|-----------------------|-----------------------|
| **Project Types**     | Console, Desktop, Web |
| **Operating Systems** | All                   |

<div class="seealso">

`DesktopApplication</api/user_interface/desktop/desktopapplication>`, `DesktopQuitMenuItem</api/user_interface/desktop/desktopquitmenuitem>`, `EndException</api/exceptions/endexception>` classes.

</div>
