Code to terminate the thread for the event queue at shutdown.