I just had this happen to me. 2005 Scion tC. 125,000 miles. Stalling at stop signs, lights and 'check engine' light would come on periodically.
April 14, 2018
REPLACE 4X SPARK PLUGS AND COILS, DIRECT IGNITION COIL, SPARK PLUG
****Drove car off their lot and immediately turned around because it was stalling at light and 'check engine' light came on again. They then replaced a wire that had burned thru the insulation and the car has NEVER run better. They told me the name of the part, but didn't write it down anywhere. I will get that information and send that along to you. I believe that the new plugs helped but the replacement of this burned out wire seemed to be the main cause of the stalling. They also said buying gas at Sam's and grocery stores contains water, which ruins the engine. Truly honest people I dealt with. They replaced that wire free of charge because they missed it during the diagnosis. I am retired and count on the honesty of people I deal with not to gouge me due to living on a fixed income.
Hope this helps!