Bring sanity to the tor side of the PT shutdown process.
This is the final phase of my great PT shutdown process cleanup as a follow up to #15545 (moved).
Now that there's a portable mechanism to signal termination to PTs (close the stdin), we should change the PT shutdown process to allow graceful termination to look like this:
- Close stdin (and on U*IX, send a SIGTERM, PT behavior here is equivalent).
- Wait for a grace period (~1 sec?)
- If the child still is not dead, send a SIGKILL/TerminateProcess(). (Failsafe)
This fixes #9330 (moved) in that, PTs that wish to trap a graceful shutdown on Windows have a way to do so, despite the final stage of the process killing the PT in the most violent way possible as a failsafe (realistically, PTs should exit shortly after step 1).