Canceling animation.Play functions after being used

I've used this as a door opening script:

function OnControllerColliderHit(hit : ControllerColliderHit)

{

  if(hit.gameObject.tag == "Door")

  {

     hit.gameObject.animation.Play("Door_Open");

  }

}

How do I cancel the "hit.gameObject.animation.Play("Door_Open");" function after the animation been played?

A function can't be "canceled" from outside the function, but that's not necessary. Play() just starts the animation. With Stop() you can stop a running animation at anytime.

But i guess you just want the animation to stop automatically at the end. You have to set the wrapmode of your animation to WrapMode.Once, that's all.

In your case it should be

hit.gameObject.animation["Door_Open"].wrapMode = WrapMode.Once;
hit.gameObject.animation.Play("Door_Open");