Fix handle leaks

/cc @trevnorris @tjfontaine