Hi,
Here's the story. I bought a 98 Legacy with only 40K miles, but with the "check engine light" on, from a dealer in New Jersey, got on the turnpike, and it stalled at the first tollbooth. It started fine, but the engine sounded like a lawnmower, was shaking terribly, and had a fraction of the power it was supposed to. I brought it back to the dealer, he started it up, and it was fine. We later figured out that if the car is doing this, you can turn it off, let it sit 5-10 seconds, and when you start it up, it's fine.
Sometimes, the car will start running badly, shaking etc, without stalling first. Always, though, it's when the RPMs have gone from high to low pretty quickly, like when stopping, or shifting into neutral between gears. However, it doesn't always happen, so it's difficult to replicate.
He had me bring it to a mechanic, who replaced injectors and the Idle Air Control motor. When I picked it up, the CEL was off, I thought everything was okay. First time I get on a highway, though, and slow down due to traffic, it stalls, I restart, it sounds terrible and has no power, and the CEL is back on.
The dealer had me bring it to another mechanic, who took out the EGR valve and told me to drive it for a week or two. If the car doesn't run badly, the EGR was the problem. It ran very good after this for several days, but occasionally stalled. Then, one day it stalled and shook and had no power. It did this a few times, but not near the frequency it had been when I first bought it.
Then, I took it on a 100-mile trip, and it started stalling almost at every stop sign, sometimes running badly afterwards, sometimes not.
As it is now, I'm taking it back to the second mechanic, who will put in a new EGR and then do the "next thing".
What could possibly be wrong with this otherwise wonderful car?