Support for main loop and confignsaving on exit.