Closing writer before dispose to fix "Too many open files" on MacOSX