Arduino Uno WiFi Rev2 hangs if WiFi connection disrupted

This is the original code that I am running from the example and I cannot replicate what you are saying is happening. If the client.connect(server, 80) fails, it drops through to the else and sends a message to the serial monitor. Which is where I suggest calling the new createConnection method.

// this method makes a HTTP connection to the server:
void httpRequest() {
// close any connection before send a new request.
// This will free the socket on the Nina module
client.stop();

// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.println("GET / HTTP/1.1");
client.println("Host: example.org");
client.println("User-Agent: ArduinoWiFi/1.1");
client.println("Connection: close");
client.println();

// note the time that the connection was made:
lastConnectionTime = millis();
} else {
// if you couldn't make a connection:
Serial.println("connection failed");
}
}