I also encountered a problem very similar to yours, but my program does not use TerminateThread, and my stack information is
ntdll!RtlpWakeByAddress+0x7b
ntdll!RtlpUnWaitCriticalSection+0x2d
ntdll!RtlLeaveCriticalSection+0x60
ntdll!LdrpReleaseLoaderLock+0x15
ntdll!LdrpDecrementModuleLoadCountEx+0x61
ntdll!LdrUnloadDll+0x85
KERNELBASE!FreeLibrary+0x16
combase!FreeLibraryWithLogging+0x1f
combase!CClassCache::CDllPathEntry::CFinishObject::Finish+0x33
combase!CClassCache::CFinishComposite::Finish+0x51
combase!CClassCache::FreeUnused+0x9f
combase!CCFreeUnused+0x20
combase!CoFreeUnusedLibrariesEx+0x37
combase!CoFreeUnusedLibraries+0x9
mfc80u!AfxOleTermOrFreeLib+0x44
mfc80u!AfxUnlockTempMaps+0x4b
mfc80u!CWinThread::OnIdle+0x116
mfc80u!CWinApp::OnIdle+0x56
mfc80u!CWinThread::Run+0x3f
mfc80u!AfxWinMain+0x69
zenou!__tmainCRTStartup+0x150
kernel32!BaseThreadInitThunk+0x24
ntdll!__RtlUserThreadStart+0x2f
ntdll!_RtlUserThreadStart+0x1b
Did you finally solve it? Feeling the reply