Fix crash at the end of the game