Close dat file before copying it upstream and flush the upstream file before releaseing the lock.
Merge pull request #2024 from mommsen/fixCorruptionOfDatFiles

DAQ fixes -- Fix corruption of dat files