Is there a method that calls when a game Closes via the Close Button?

In Windows or OSX, when you click the "Close" button, in a Windowed game, is there something I can tie the game to for functions, so I can throw up a "Are you sure?" message box?

Sometimes the game crashes when I close it with this method, so I'd like to be able to catch it, just incase...

OnApplicationQuit is called, you can stop it from quitting with Application.CancelQuit(); inside there