Fixed crash when changing state to the main menu.