Explicitly close agent connection in top level agent class.

Fixes #459
Changelog re #459
Merge branch '1.13' into 1.14