Diesel engine dies

I would look too at the stop solenoid needed to stop a diesel. It is activated at the ignition switch and a check in wiring might be worthwhile. The solenoid is obviously working, perhaps being engaged when it shouldn’t by loose or exposed wiring.