close output files when finished in the dump functions.