My 2007 started doing that last year. The car would actually shut off once or twice at stops but revving it kept it alive long enough to get home. Then the next few days the car was back to normal. The telltale sign that it is going out altogether was when electrical things started not working right, even got a message on the stock head unit. Then it died on me while driving, all electrical shut off; gauges, lights, everything. I had the alt and battery tested, the alternator wasnt doing its job. Ended up having to replace the alternator, since then everything is back to normal 100% and happy again.
Similar issue happened with my sisters '07. Her shop said it was the battery only for the new battery to die on her while on a trip. Replacing the alternator fix the problem and she had been issue free for the past year.