Bugfix to "Ensure that the socket is closed".
(Let the socket be accessible to the code in question.)