I see, here is a hacky way:

Code:
...
if(file_date("your\path\stop.txt")>0){
    ... save data here ...
}
...



Create stop.txt shortly before stopping the script, and delete it right after.