Send quit on connection close.
Move some TCP code around.