/// <summary>
        /// Uninstalls the hook.
        /// </summary>
        /// <returns></returns>
        public bool UninstallHook()
        {
            lock (lockObject)
            {
                if (hook == null)
                {
                    return(false);
                }

                Global.OnProcessExit        -= Global_OnProcessExit;
                Global.OnUnhandledException -= Global_OnUnhandledException;

                hook.OnHookCalled -= Hook_OnHookCalled;

                hook.UninstallHook();

                hook.Dispose();

                hook = null;

                return(true);
            }
        }
 private void Window_Closed(object sender, EventArgs e)
 {
     mh.UninstallHook();
 }