I have a problem with my app. I really need to kill it when user clicks "Exit". I've tried both methods listed in the question header, and here's the problem: I have a persistent (foreground) service performing work, so there is a tray icon for my app. When user switches to my app via this icon and then presses "Exit" - the app is kill, but Android immediately restarts it. If the users switches back to the app using any other method (not the service icon) - application is not restarted upon exit.
So, what is the reliable way of killing application?
P. S. There's always only one activity in the application, if that is of any importance.