Ensure connections are properly closed on object destruction

Signed-off-by: Vincent Besanceney <vincent@b9company.fr>
Merge pull request #291 from vincentbesanceney/fix_connleak

Ensure connections are properly closed on objects destruction.