Add 2 functions to your dll and export them.
Initialize { monitor.startThread(); } and
Uninitialize () {monitor.stopThread(); }.

Call Initialize() from the process after the dll is loaded. Call Uninitialize() before you unload the dll.
Thus you avoid DLL_ATACH/DETACH, and cleanly exit the thread.