Don't sync files to disk if deleteFilesAfterClose is true.

Fsyncing files if deleteFilesAfterClose causes an unneeded latency when the files are going to be deleted anyway. This fix checks if the files will be deleted immediately before syncing.