close socket before quit()