Application.Quit() not working with collider

I have this bit of code that supposedly when two objects collide will exit/quit the game. Using the Debug.Log in the editor, I know the two objects are colliding with each other. But after building and trying, found out the Application.Quit() is not working.

void OnTriggerEnter()
    {
	    Debug.Log("Hit quit button");
        Application.Quit();

    }
}

What did I do wrong? Does anyone know why it’s not working? And can anyone tell me what’s the best way to do it? Thank you so much.

Just keep it simple guys…application.quit(); will never work on Gamescene…it will work after the build is transferred to the Device…i am using the same for ios and android devices and it’s works fine so Don’t penic… just Relax and Enjoy

Try this code:

void OnTriggerEnter()

{

Debug.Log(“Hit quit button”);

StartCoroutine(“Quit”);

}

}

IEnumrator Quit()

{

yield return true;

Application.Quit();

}