Added a close socket on shutdown