Close the client socket on exceptions.

As-is, a Nailgun session may not close the socket if an exception is
encountered. The session should be closed in the _finally_ block.
Mark as `static`.