Cutting out the rail is unlikely to cause huge damage, and welding something directly to the rail would take quite some time and be noticeable. Just putting a few sensors every few meters and networking them then stopping the train would work.
But I am also surprised how well it works. I think people just don't suck as much as one would expect.
The US has a total length of about 300 000km of railway network and that probably counts multi-track connections once. And it doesn’t include subway or anything. So that would be a lot of sensors that need to be placed and maintained. And you’d need to except some failure of sensors, so you cannot just stop if a single sensor goes haywire.
It’s certainly not impossible, but also not trivially done.
But I am also surprised how well it works. I think people just don't suck as much as one would expect.