How to Exit Application in Android on Back Button

Hello All
I need code to exit my application when I press back button on android device.
But It seems that " Application.Quit()" is not executing.
Please help

void Update(){
if (Input.GetKeyDown(KeyCode.Escape))
Application.Quit();
}

or in .js

function Update(){
  if (Input.GetKeyDown(KeyCode.Escape)) 
   Application.Quit(); 
}

if (Input.GetKeyUp(KeyCode.Escape))
{
if (Application.platform == RuntimePlatform.Android)
{
AndroidJavaObject activity = new AndroidJavaClass(“com.unity3d.player.UnityPlayer”).GetStatic(“currentActivity”);
activity.Call(“moveTaskToBack”, true);
}
else
{
Application.Quit();
}
}

This code is in C# if the user is on Android device or on PC the app will exit.

It will only work in the case of android only.
if(Input.GetKeyDown(KeyCode.Escape))
{

Application.Quit();

}