Fixed the crash when quiting the game.

[FIX] Fixed the crash when quiting the game.