Thread safety

I did that to set the handler to null, otherwise if close() is called a second time then the handlers are executed again. I spotted this in the testsuite when an endHandler calls testComplete() because testComplete() is called twice and made the test fail. Perhaps there is a better way to do it by not setting to null.