Ensure ssl sockets are closed in the event of failures shutting down the connection