Try to fix shutdown test in edge cases (#86464)
Fixes https://github.com/pytorch/pytorch/issues/85259
See the issue for debugging details.
tl;dr: when a worker thread is actually used, make sure it is initialized before exiting.
Yes, it is very unlikely it will take >10s to initialize but it is what seems to happen.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/86464
Approved by: https://github.com/soulitzer, https://github.com/ezyang