Could be the key switch but I would suspect the fuel stop solenoid. The solenoid is usually around the top of the engine. Turn your key on but do not start the motor. You should hear a click, this is the fuel solenoid opening to allow fuel to your engine. When you turn the key off you should hear another click (might be delayed a few seconds), this is the solenoid shutting off the fuel. Cutting off the fuel flow is the only (well cheapest and safest) way to shut a diesel down. I suspect a bad solenoid or corroded wiring.
BTW, Welcome to the forum!