fix unhandled exception caused by disposing waithandles