Handle game.ended event to avoid memory leaks