[Java] How do I stop my timer upon the completion of the game?

So I am working on a simple trials racing game, everything is working well. Except I don’t know how to stop my timer when it gets the final level.

I am using

private var startTime : float;
var textTime : String;

function Start() {
startTime = Time.time;
}
function OnGUI () {
var guiTime = Time.time - startTime;

var minutes : int = guiTime / 60;
var seconds : int = guiTime % 60;
var fraction : int = (guiTime * 100) % 100;

textTime = String.Format (“{0:00}:{1:00}:{2:00}”, minutes, seconds, fraction);

GetComponent(GUIText).text = textTime;

}

as my timer script, and I am using “DontDestroyOnLoad” to keep the timer running between levels.

I don’t know enough of coding to stop the timer (introductory class into Unity). I don’t want to destroy my timer, I just want the timer to stop after entering the final portal and display the time they received.

Just place a timer in Update and stop it when you need it:

var timer : float;
var gameOver : boolean;

function Update()
{
      if(!gameOver)
      {
              timer += Time.deltaTime;
      }
}

function OnGUI()
{
       //place timer.ToString() in a label somewhere in the correct format.
}