Make sure the main loop runs as a single_shot when not running indefinitely.