Flush data at the end