All I/O requests must complete before shutdown on Windows
In the non-threaded RTS, in order to fix problems with shutdown of DLLs we made it so that the RTS would wait for any outstanding IO request threads to exit before the RTS exits (otherwise the threads return later to find the DLL is missing and crash).
Unfortunately this means if you fire off a long threadDelay and then the program ends, the RTS won't exit until the threadDelay expires, even if the original Haskell thread has been killed. In the threaded RTS, we don't have the threadDelay problem (any more) because of the IO manager thread, but we do have a similar problem with outstanding I/O requests (untested).
It's perhaps worse in the threaded RTS, because we don't wait for these I/O requests to exit - they are in foreign calls, and we don't currently wait for foreign calls to complete before exiting (this is a bug, in fact, similar to the original DLL shutdown bug).
I'm not sure what to do, here are some options:
the I/O request threads should be terminated, somehow.
maybe we need two ways to shut down the RTS: forcibly, for program exit,
and more carefully, for DLL shutdown.
when shutting down a DLL, we should wait for and/or terminate outstanding
foreign call threads.