Do you mean when the "Back" or "Home" buttons are clicked? Or when app is terminated? You can't actually track the termination event.
To track the close event, you can override "onBackPressed" event.
To trach "Home" button, override "onKeyDown" and track key code "KeyEvent.KEYCODE_HOME".