If it’s not working, make sure your script is active in the scene. You can add a Debug.Log()
line to see if it’s working in Play Mode.
if (Input.GetKeyDown("escape"))
{
Application.Quit();
Debug.Log("Quit Game.");
}
The message “Quit Game” will show up in your console after pressing escape if the code is actually running.
Also, here’s how to use code tags: Using code tags properly