You cannot fully prevent anything. Planes crash, trucks crash, ships crash, cars crash. It's the cost of doing business in a modern society. In the case of the railroads, 99.97% of hazardous materials make it to their destination without incident. I'd say that's a stellar record.