public static void StopHook() { if (CheckHook()) { return; } KMHook.UnhookWindowsHookEx(_hookID); KMHook.UnhookWindowsHookEx(_mouse_hookID); _hookID = _mouse_hookID = IntPtr.Zero; Thread.Sleep(10); //Give some time for it to apply }