When a connection fails to open, check for null on the returned connection before attempting to close it.