Make sure socket is closed after failed connection attempt.