Close any open sockets when reusing a curl handle and reopen the socket whenever we're retrying stratum.