Unity raises this event when the Player application is quitting.
Add an event handler to this event to receive a notification that the application is quitting.
Notes: The Application._quitting event is raised when the quitting process cannot be cancelled. Examples of when this event is not raised are: when the Player is forced to quit or if there is a crash. Application.quitting is invoked when exiting Play mode.
iOS applications are usually suspended as they don't quit like applications on other platforms. Use OnApplicationPause to capture these events.
On UWP Apps, there's no application quit event; therefore, consider using OnApplicationFocus event when focusStatus equals false.
To prevent the player application from quitting, refer to the Application.wantsToQuit event.
Additional resources: The activity lifecycle
using UnityEngine;
public class PlayerQuitExample { static void Quit() { Debug.Log("Quitting the Player"); }
[RuntimeInitializeOnLoadMethod] static void RunOnStart() { Application.quitting += Quit; } }
Additional resources: Application.wantsToQuit, The activity lifecycle.