CHEF-4625: Explicitly close temp files to prevent sharing violations