Need Help making my game return to Main Menu after a level ends

Hello, In My Game (IPhone Game) I have ten different levels. I have been trying to make it so after someone completes a level it loads the main menu, for this I was using a script from the "Penelope" Tutorial but it seemed to not be working.

I was Wondering if anyone had a better way of doing this or a way to fix this. Thanks.

Here is an example of the part of the script:

private function EndGame()
{
    var animationController : AnimationController = GetComponent( AnimationController );
    var prefab : GameObject = Instantiate(guiMessage);
    var endMessage : GUIText = prefab.GetComponent( GUIText );

    if(carrying >= winScore)
    {
        //Player wins
        endMessage.text = "You win, Cheese!";
        PlayAudioClip( winSound, Vector3.zero, 1.0 );
        animationController.animationTarget.Play( "WIN" );
    }
    else
    {
        //Player loses
        endMessage.text = "No Cheese For You!";
        PlayAudioClip( loseSound, Vector3.zero, 1.0 );      
        animationController.animationTarget.Play( "LOSE" );     
    }

    // Alert other components on this GameObject that the game has ended
    SendMessage( "OnEndGame" );

    while( true )
    {
        // Wait for a touch before reloading the intro level
        yield WaitForFixedUpdate();
        if ( iPhoneInput.touchCount > 0 && iPhoneInput.GetTouch( 0 ).phase == iPhoneTouchPhase.Began )
            break;
    }

    Application.LoadLevel( 0 );
}

Also here is the receiver to the "OnEndGame:

function OnEndGame()
{
    // Disable joystick when the game ends  
    moveJoystick.Disable();
    rotateJoystick.Disable();

    // Don't allow any more control changes when the game ends
    this.enabled = false;
}

you can simply add this line at the end of OnEndGame() function :

Application.LoadLevel(0);// loads the first level of game

if your main menu is the first level.