Remove the vacuum controller to get it out of the way and then you should be able to see the 10 mm fastener(s) holding the shut off valve on. I don't remember if there was one or two fasteners. After you get the fastener out you pull the shut off device out "toward" the block. This lets it clear the oil filter housing. Install the new one in reverse of the one you removed. Make sure you get it in the "catch" inside the injection pump.
Pretty straight forward job.
"shut offs sometimes" bothers me. I don't think it would shut off at all if it was the shut off actuator. Put your mighty vac on the vacuum line to the shut off device and see if you can shut if off by applying vacuum. If you can then it is not an issue with the shut off device. The next thing to check is to see how much vacuum you are getting to the device when you turn the key off. If you have alot of leaks in other places of the system then you may not have enough vacuum to activate the shut off device enough to shut the engine down.