wait for the writer to finish before exiting