close socket earlier