Platforms have the same length as trains, and all of them have exit signals close to the end of platform, so AI trains must stop very close to the signal (around 5m). Trains stop at the correct place in all stations, except at the terminal station. We tried many commands ($keepclear, $terminal, $closeupsignal, $extendplatformtosignal, ...) and none of them worked.
Since this is the last station, the path ends at this platform, and the exit signal is at danger. I suspect there is some part of the code forcing the train to stop well in advance of that stop signal. If I change this signal so it always stays clear, the train stops at the right position.

Due to the short platforms, this causes an undershoot, and the train hardly releases the entry points.

The weird thing is that the train correctly stops at the other terminal station, which has a similar platform length and track layout.

Is there something that I'm missing?