Improved the code to kill the event handlers after a timeout, cleaning the queue.