# OnApplicationQuit()

> Sent to all active GameObjects before the application quits.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)

```csharp
public void OnApplicationQuit()
```

### Remarks

In the Editor, Unity calls `OnApplicationQuit` when exiting Play mode. It's called on all script components, even if the component is disabled. Unity doesn't send this message to inactive GameObjects. Platform-specific considerations: \* iOS applications suspend rather than quit, so `OnApplicationQuit` won't be called. Use [MonoBehaviour.OnApplicationPause(bool)](/engine/6000.5/script-reference/unityengine/monobehaviour/onapplicationpause.md) instead for handling app suspension and cleanup. \* On Windows Store Apps and Windows Phone 8.1 there is no application quit event. Use the [MonoBehaviour.OnApplicationFocus(bool)](/engine/6000.5/script-reference/unityengine/monobehaviour/onapplicationfocus.md) for handling app loss of focus. \* The Web platform doesn't support `OnApplicationQuit` because of the way browser tabs close. For a workaround, refer to [Interaction with browser scripting](/engine/6000.5/manual/platform-specific/webgl/develop/interactingwithbrowserscripting.md) in the manual. \* If the user suspends your application on a mobile platform, the operating system can quit the application to free up resources. In this case, depending on the operating system, Unity might be unable to call this method. On mobile platforms, don't rely on this method to save the state of your application. Instead, consider every loss of application focus as the exit of the application and use [MonoBehaviour.OnApplicationFocus(bool)](/engine/6000.5/script-reference/unityengine/monobehaviour/onapplicationfocus.md) to save any data.

### Examples

```csharp

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void OnApplicationQuit()
    {
        Debug.Log("Application ending after " + Time.time + " seconds");
    }
}
```
