Proper exiting when the last menu is closed