If it's instant shutoff upon releasing key, I'd guess fuel solenoid or switch kickback as described by Bird.
If it fires another rev or two after that, and then dies, I'd check fuel filters. My VW diesel Rabbit pickup had this problem once. After shutdown, enough fuel seeped back in for a restart. As soon as the engine fired for a few revs, the pump coundn't draw fuel through the clogged filter fast enough and it would stall. Less likely, though possible, is an air filter so badly clogged that not enough air is being drawn in through the intake valves. In either of these cases, I'd expect to hear knocking and to feel a strain on the entire crankshaft system.
This is nothing new to most people on this site, but for those not familiar with diesel engines, a diesel doesn't have an "ignition" system, only a "starter" system. The compression stroke builds a much higher compression ratio than a gasoline engine. Following the Ideal Gas Law, PV = NKT, the rapid high compression builds so much heat that when the fuel is injected, the high temp of the compressed air causes instant oxidation with no spark or spark plug necessary to "ignite" the fuel and oxygen. Glow plugs (and block heater in winter), provide the extra heat needed when the block is cold. The starter turns the entire crankshaft, pistons, rods, for the first couple of revs until the first couple of explosions occur. After the key is released, the starter disengages and the inertia of the crankshaft, and pressure from expanding gasses in the other cylinders, is enough to drive each succeeding compression stroke through subsequent injection and burn.