Hello,

DLL_THREAD_DETACH is called when a thread is exiting in a clean manner. Do you have such a thread in your process you know it's doing this ?
DLL_THREAD_DETACH is not called when a thread is terminated.

I would suggest also to remove the Sleep(2000) line and move the 2000 timeout inside WaitForSingleObject() call, it's more efficient.

Also, after SetEvent(this->stopFlag), I would check that the thread has exited before closing the event handle. (for example with a WaitForSingleObject(this->threadHandle, sometimeout))
This is becouse the thread might be executing the Sleep(2000) while the event handle is closed, therefore WaitForSingleObject(this->stopFlag,0) would never return WAIT_OBJECT_0 and you'll never break the while() loop.