close link after all data has been sent.

(also, send extra newline to indicate the end of data)