Well, you should not close your applications, as the system deals with this. Refer to posts / topics in other answers for more information.
However, if you really want this, you can still call System.exit (0); as in any other Java application.
EDIT
ActivityManager actmgr = (ActivityManager) this.getSystemService (Context.ACTIVITY_SERVICE); actmgr.restartPackage ("com.android.your.package.name");
I remembered something. I tried to use this code to restart my application, but I only managed to kill my application. You can try and see if this works for you.
Shade Feb 28 2018-11-11T00: 00Z
source share