close sockets before throwing errors during handshake