Properly close curl connection