Fixed an error when closing the game