Explicitly close agent connection in top level agent class.

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