Looked at android documentation and it appears that we don\'t have the ability to know when an app shuts down. Whether it was explicitly by the user or automatically by the
Make a BaseActivity extending Activity in your Application and extends this BaseActivity instead of Activity.
In this BaseActivity override the onDestroy() method.
Like
@Override
protected void onDestroy() {
super.onDestroy();
//Write the code that you want to do if the application terminates
}