Close socket on unload