Don't end using a resource in a generator until after yielding