Hello and welcome to Just Answer, my name is XXXXX XXXXX I thank you for requesting me to assist you with your concern.
The fact that it starts right up once you pull off the road tells me one of two things. Most likely this is a issue with the main harness for the engine. 2003 and early 2004 engines had issues where the harness would chafe and ground out on the engine itself and would stall the engine. Usually when this happens you will see all the lights in the dash (fuel in water and glow plug wait light) will come on when this happens as well. Most likely the harness is shorting out somewhere it runs along the intake and valve cover under the area of the ficm module. I have found the best way to try to pinpoint the place it does this is to let the truck run and take a long pry bar and wiggle and move the wiring harness until it stalls. once you get this to happen inspect that part of the harness and you will find a damaged area.
Let me know what you find, I will assist you further if necessary.