Agent: try and close connection under all circumstances
Merge pull request #13 from rud/bugfix/ensure-connection-closed

Agent: try and close connection under all circumstances