Call another function during wait for seconds

I have a code like below

StartCoroutine(“MyFunction”);

function MyFunction()
{
//Some Line of codes
Yield WaitForSeconds(5);
//Rest of codes
}

But during that WaitForSeconds user may press another button which cause another function call.
my problem is that when the other function is called, codes after the WaitForSeconds command do not run.
Can anyone help me to know what the problem is? and also the solution!

function Start()

{

StartCoroutine(“MyFunction”);

}

function MyFunction()

{

Yield WaitForSeconds(5);
Debug.Log(“After 5 second called”);

}

function ButtonEvent()

{

StopCoroutine(“MyFunction”);

Debug.Log(“Button Clicked”);

}