Fix crash when pressing ESC during connection