[BUG] only close socket if it exists