Dynamically loaded dll crashing program

I have an application that loads a dll dynamically. when this DLL is loaded, it starts it's own thread that creates it's own window. later, the DLL is unloaded using FreeLibrary(). the problem is that if the main thread in the DLL has not terminated by the time FreeLibrary is called, then the main application crashes. So I need a way to determine if the DLL has threads/windows created so that I can terminate them manually before trying to unload the DLL. Is there any way to do this?
Topic archived. No new replies allowed.