Fix end game window conflicting with ingame menu

This causes the menu to close itself when the game is over.

Fixes #6311.