Fixed a deadlock between Accept() and Close()