Last time I had a car do that, one of the push on coil wires was loose. Vibration would cause it to wiggle, and that caused the bad idle, and sometimes to just quit. I cut off the old slip on wire end when I found out that was the cause, and put on one that tightened down with a nut, and the problem was solved.