our app depends heavily on data stored on the local filesystem. Therefore i have to make sure this data is saved. Currently, whenever there are changes in the data, i save the whole file containing the data instantly to make sure the data has been written to the local filesystem. However, this seems inefficient to me. Is there a way to detect when the app closes and in that case to call a function which is guaranteed to finish some file operations?