Auto-close when the main process no longer runs