I agree with disconnecting the shift cable and shifting in and out of gear. The reason I would do this is not to test the neutral safety switch it would be to test the control box. The throttle position sensor is located in the box. Leaving the control box in the neutral position ( engine running) shifting manual at transmission ( engine runs possible issue at control box) (engine dies keep troubleshooting) The neutral safety switch should not related to the fuel shut off after start up. The neutral safety switch is wired to the starter motor solenoid. If in gear or misaligned neutral safety switch the engine will not turn over because the neutral safety switch completes the circuit to the starter. There is a circuit that feeds to the shut off valve solenoid during the start up to apply higher amperage to help keep solenoid open. Once the engine is started this circuit is not needed. If the engine is running the neutral safety switch is out of the equation.
How long do you run the engine before shifting in Gear?
What is the idle rpm?
What is the engine operating temperature at when shifting in gear.
What is the max rpm in neutral that you can run up to?
Any smoke at idle?
Any running codes ?
How does the engine sound ?
Does it appear to be running on all 4 Cylinders?
Have you tried running the engine on a remote tank?
Salt water boat? Have you checked exhaust elbow for restriction?
Air filter clean ?
Fuel filters clean?
No evidence of fuel leaks or air leaks in fuel system?
fresh fuel ? old fuel?
What was running condition before ECU was replaced?
A diesel engine before common rail was simple ( air in without restriction) (clean fuel pumped at high pressure with no air in system to injectors rack driven, compression, and non restricted exhaust. These principles are all still used in the common rail but the are many electrical components doing what the basic components use to do. In troubleshooting start with the basics. Air in, fuel in, exhaust out. Next is each cylinder firing? If an engine is running and goes into gear and dies. (1) the reverse gear is locked up, or running gear is fouled (2) the engine doesn't have enough power to turn the prop. (3) fuel is being shut off by an electrical fault, not enough fuel, air in fuel, bad fuel, restricted air, exhaust, injectors,.....