Fixed a deadlock on darwin and x11 hosts.  Hooks should restart properly for those platforms.
Made some small adjustments to the thread cleanup procedures for darwin and x11 platforms.