close resources as we iterate over them