fix minor issue: we should set connected to false after we closed the socket