closing socket connection properly