The Escape Button is a Feature
Exit game with the escape key
Objective: Exit game when user presses the escape key
I’m gonna add a feature to exit the game when the player presses the escape key. In order to do that I add the following code in the GameManager script within the Update function.

If you want to quit the game from the unity editor, you have to uncomment the line UnityEditor.EditorApplication.isPlaying = false.
And that’s all! You can exit game using the escape key.
