yield WaitForSeconds not returning

I am trying to use WaitForSeconds at the end of a level, but the line after yield WaitForSeconds is never executed. I have tried calling end level with StartCoroutine(endLevel) but that made no difference.

function OnTriggerEnter (hit: Collider) {
    if (hit.gameObject.tag == "wormProjectile")
    {
    Destroy(hit.gameObject);
    var exp = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
    Destroy(gameObject);
    num_cannon=num_cannon-1;
    if (num_cannon<=0)
        {
        endLevel();
        }
    }
}

function endLevel()
{
    TextMsgControl.message = "Level Complete";
    WaitForSeconds(5);
    TextMsgControl.message = "Game Over";
}

Any help appreciated.

You're destroying the object before the waitforseconds is over, so it'll never finish it

What you probably need to do is start the coroutine on another object which isn't going to die