fixed bug in mine closing curl handle before error checking