Finalize the file