I don't know the answer to the question, but if you tell us a bit more about the data you want to persist we may be able to suggest a better solution. I presume you already know that flow and context data can be persisted automatically.
Thanks for you comments. The data is active alarms from an automation system. When the flow shuts down i wanted to complete all the active alarm's (calculate the duration) and persist. When the flow starts up i then get the persisted completed alarms and push them to the history database.
Yes, i guess one solution would be to 'store to file' the active alarms flow variable. I just thought that is was cleaner or nicer to not be continually writing to the file system.