I would like my app to retain state and hoping to trigger that based on the home key being clicked.
If I cant do that I guess I just need to retain state with each action.
I think you can intercept the close event but I'm not sure how much time you have to perform any actions. As you suggest it might be easier to call everything through a filter like function that saves/retrieves state if needed.
listen to the application's close event - there's an example in the KitchenSink.