Clean up connection objects better when closed.

Connections need to be reset to their basic state when they get
closed, in order to enable their reuse.