also register the writer for closing
close writer