1 km long train traveling on a straight track at a constant speed V of 90 percent of the speed of light.

At some point in the ground near the track there is a flashlight, when the last wagon passes the flashlight, a beam is sent to the engine. on the engine there is a facility that once it receives the beam its stops the train.

Relatively to a passenger sitting at the last car, the train is in rest, so when the train will stop, the distance from the last wagon to the flashlight will last 0.9 km

Relative to an observer standing on the ground next to the flashlight, if we take into account the Lorentz contraction the train length is 0.43 km, so the time it takes the light to reach the engine will be 0.43/0.1C second. During this time the train traveling at 0.9C, so the train begins to stop after 3.87 km.

My question is when the train really start breaking down?

Does the answer changes if the flashlight is located not on the ground but on the train?

Apologized for my English