Close the socket upon erroneous exit as well.