crt: Don't run TLS destructors for the main thread if exiting via _exit or ExitProcess

For these cases, the TLS destructors are normally executed by
the callback set up by _register_thread_local_exe_atexit_callback,
but if this is bypassed (if exiting via _exit or ExitProcess),
skip these callbacks.

This differs from what MSVC does, but matches what the C++ standard
says should happen.

Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/crt/tls_atexit.c b/mingw-w64-crt/crt/tls_atexit.c
index 1062106..27ffb84 100644
--- a/mingw-w64-crt/crt/tls_atexit.c
+++ b/mingw-w64-crt/crt/tls_atexit.c
@@ -124,12 +124,12 @@
      * main, or when a DLL is unloaded), and when exiting bypassing some of
      * the cleanup, by calling _exit or ExitProcess. In the latter cases,
      * destructors (both TLS and global) in loaded DLLs still get called,
-     * but only TLS destructors get called for the main executable, global
-     * variables' destructors don't run. (This matches what MSVC does with
-     * a dynamically linked CRT.)
+     * but none get called for the main executable. This matches what the
+     * standard says, but differs from what MSVC does with a dynamically
+     * linked CRT (which still runs TLS destructors for the main thread).
      */
-    run_dtor_list(&tls_dtors);
     if (__mingw_module_is_dll) {
+      run_dtor_list(&tls_dtors);
       /* For DLLs, run dtors when detached. For EXEs, run dtors via the
        * thread local atexit callback, to make sure they don't run when
        * exiting the process with _exit or ExitProcess. */