close() properly when triggered in connection handler
Merge pull request #227 from j-salazar/memleak

close() properly when triggered in connection handler