Ignore Windows FLS destructors during process exit
Ignore Windows FLS destructors during process exit

There's a quirk on Windows where exiting the process will still run fiber-local
storage destructors for the thread that called ExitProcess() (but only for that
thread). pthreads-based platforms don't call any key destructors on exit, and
_libdispatch_tsd_cleanup() assumes this. So, on Windows, calling exit() from a
queue thread will trigger the fatal error in _dispatch_frame_cleanup().

Implement a reliable method of detecting whether the process is exiting, and if
it is, ignore calls to _libdispatch_tsd_cleanup().

Signed-off-by: Kim Topley <b240e9af83531ac049af314c640f722869aeb57d@apple.com>

apple/swift-corelibs-libdispatch,apple/swift-corelibs-libdispatch,apple/swift-corelibs-libdispatch,apple/swift-corelibs-libdispatch