Probably, at the end, this is work for the curl_and_print() function (or whatever name you prefer, @LeandroGuillen :) rather that for ending teardown routines.