fix a socket close bug