I am working for a railroad company at the moment, we learned cool stuff during onboarding.
Modern train have an electromagnetic emergency brake system that uses a large magnet lowered onto the rail to stop.
Also the standard braking system using fluids has a clever indirection where it does not activate the brake when pressure rises but when it drops. This is because when a waggon gets loose and the braking line rips and fluids get's out, the waggon should immediately brake as soon as pressure drops.