Handling the end of the game.