I have tried the above link but it’s not working.
Application.Quit() does not work while in the Unity editor. If you are running the game in the Unity editor use UnityEditor.EditorApplication.isPlaying = false;
Here is a function that I commonly use
public void QuitGame()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}