Do not run any cleanup if the program is exiting anyway
From keno's PR - this avoids the potential hang in blas_thread_shutdown where we may wait for threads to exit while they are waiting on the loader lock from DllMain
@@ -50,6 +50,9 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
gotoblas_init();
break;
case DLL_PROCESS_DETACH:
+ // If the process is about to exit, don't bother releasing any resources
+ // The kernel is much better at bulk releasing then.
+ if (!reserved)
gotoblas_quit();
break;
case DLL_THREAD_ATTACH:
