making sure socket is closed