Close the generator when writing.