we need to close the writer, otherwise we can hang in certain situations