Hide UI immediately after leaving the main loop.