Close cURL handle before returning

Fixes #39, #59