close socket on terminate