RGSS3: Game Shutdown?

In RGSS3 (RPG Maker VX Ace), is there a way to execute some code whenever the user quits their game?


If so, does it cover all these cases?


- User went through the menu > Shutdown


- User went through the menu > Quit to title


- User pressed ALT+F4, or pressed the X on the game window


I'm trying to log information about how long players play my game (to check the balance) and I would like to log something out when they quit.
You can add scripting to the Shutdown or Quit to Title functions to do something before the game closes/returns to title, but it is extremely hard to add something to cover the X/Alt-F4/forced shutdown cases because AFAIK Ruby doesn't have anything to check what Windows is doing (so you'd need to create a bridge to another programming language).  This would be easier to do in MV, however.
You can add scripting to the Shutdown or Quit to Title functions to do something before the game closes/returns to title [...]



Okay, how exactly do I do this? Which built in class/functions do I look at? I already looked at most of the built-in classes via the VX Ace Script Editor, but I didn't find anything appropriate.
Okay, how exactly do I do this? Which built in class/functions do I look at? I already looked at most of the built-in classes via the VX Ace Script Editor, but I didn't find anything appropriate.



As an example, you could add logic to command_shutdown in Scene_Title.  You would probably want to execute some of the Save logic (see the DataManager module) after you add in your extra logic but before the game actually shuts down.
As an example, you could add logic to command_shutdown in Scene_Title.  You would probably want to execute some of the Save logic (see the DataManager module) after you add in your extra logic but before the game actually shuts down.



That seems to cover most of what I want. Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/rgss3-game-shutdown.63853/