I want to track when the program is ended and you stop the code.
Progress notifier ?
Similar to above, using checkpoints in your code that can activate a visible progress bar in your app ?
Without seeing "the code" and without further explanation of what you want to do, difficult to advise further...
I want to save a value in a tiny db for when the code is stopped.
Basic stuff:
Did you try it, did it work ? Can't see why not. Also cannot see what this has to do with your topic question.
You do not need to show/hide the Listpicker button, you use the history button to open the Listpicker.