Fix main menu appearing after closed in rare cases.