so, I have a program that uses a keyboard hook, but starts it in another thread so that it can continue executing. The problem is, the only way I have to stop the mouse hook right now is to just kill the thread using TerminateThread(). However, this does not enable the thread to call the UnhookWindowsHookEx() function for cleanup (which results in glitching every program that uses that mouse hooking).
How can I send a message to this thread that enables it to safely clean itself up (using UnhookWindowsHookEx()), before ending the thread?