I have an 06 4.6 3v Mustang that's Modded so I know them pretty well, I had this same problem. Driving normal in my 07 Expy 5.4, started developing a rough idle and it would die down to an idle with the wrench light on (limp mode) it wouldnt react to the throttle at all. Pushing it into “N“, turning the key off and restarting it while still moving would reset it and it would be okay for a few days or a week. I cleaned the T-body and replaced the TP sensor. Still did it. I ended up having to do an entire timing job on it with all new Name brand Ford Phasers and M340HV Melling oil pump, new VVT solinoids, spark plugs and coils while I was at it. (Had a phaser noise is the only reason I did the timing, it wasn't related to the stalling, I dont believe) None of that was done to try to fix the prior concern. After replacing the entire T-body, a new Gas pedal fixed the problem. Its common, the throttle pedal is electronic with 3 bolts and one electrical connector. Easy fix……pretty rough diagnostics.