You can configure your self-hosted runner to run in interactive mode. In this mode, generally the runner is Offline status when it is not connected to GitHub.
To connect the runner to GitHub so that the workflow jobs can run on the runner, you need to execute ‘./run.sh’ (Linux and macOS) or ‘.\run.cmd’ (Windows) in the runner installation directory, and you will see the message like as below on machine’s terminal.
✔ Connected to GitHub
2020-08-13 07:07:49z: Listening for jobs
Keep the terminal open, then the runner will become Idle status to wait the workflow jobs to use it.
If you close the terminal or press Ctrl+C, the runner will stop the connection with GitHub and back to Offline status.
About your questions:
How do i shutdown the self hosted runner gracefully?
If you want only one job in the workflow runs on the specified runner, and after the job completed the runner can be back to Offline status automatically. You can use the ‘–once’ option when starting the runner.
On Linux and macOS:
I could just remove the runner with configure.sh but what happens if at the same time an action runs? will github reschedule it on another runner? If not what should the protocol be here?
When a job is running on a self-hosted runner, if you shutdown the runner, the job will be cancelled. GitHub won’t assigned another runner to continue running the job.