Added hooking of the game shutting down.