flush data when finished