Close application at Android Studio

We can close application with this script in android studio.

import android.view.View.OnClickListener;
buttonClose = (Button) findViewById(R.id.btnClose);
buttonClose.setOnClickListener(new OnClickListener() {
 @Override
 public void onClick(View arg0) {
 // TODO Auto-generated method stub
 Intent intent = new Intent(Intent.ACTION_MAIN);
 intent.addCategory(Intent.CATEGORY_HOME);
 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 startActivity(intent);
 finish();
 System.exit(0);
 }

});