Invoke and StartCoroutine not working

I have the following code for a simple pause menu with a quit button with a 2 second delay:

public Class Manager : MonoBehavior{

public Button quitButton;

void Start(){

void TaskOnClick(){
Invoke("QuitGame", 2);

public void QuitGame(){
EditorApplication.isPlaying = false;

But it doesn’t work. Setting up QuitGame as an IEnumerator and running a coroutine doesn’t either.

Is this something you can’t do in an AddListener?

When you try coroutine, do you call it like
StartCoroutine(MyCoroutine()) ?
In any way, try not to call method by it’s name, it is a bad practice.