The solution was simple. I forgot to assign the function in the On Click() function in the inspector of the quit button. I mistakenly had assigned SetActive() function. Now it works.
PS: Be sure to use the code in the question. There is no need to use the coroutine for making this to work.
