Support graceful shutdown of background runner
Kubernetes will send us a SIGTERM signal when the background runner
should be stopped (followed by a SIGKILL 30 seconds later if we don’t
shut down in time). Catch this signal and stop the main loop in that
case: this still lets us finish the current command (as long as it
doesn’t take too long).