close socket when check isclosed()