How do I make an object slow down to a stop?

I am currently Trying to make my train go to a stop. The character is on a moving train and I want him to pass a certain point and this will make the train slow down and stop. I currently have a stationary train and a moving background to give the illusion that the train is moving. How can I make the background slowly stop after a certain point? Any suggestions? I assumed a simple for loop would be able to do this but can not figure it out. This is my code for it.

var speed:double;
function Start () {

}

function Update () {
gameObject.transform.position.x-=speed;
}
function OnTriggerEnter () {
gameObject.transform.position.x-=0;
}

You could use Slerp function: Unity - Scripting API: Vector3.Slerp

or SmoothDamp

and apply it to your position vector. I would do that in the Update function