Based on John's information, i'd say get your battery tested. That's one lead to check out. I had a 2007 CTS that started doing really random, weird things. It would just completely "go dead"...shut off, completely...no lights, no NOTHING, completely dark car. Then it would restart and be completely fine for a few hours, or weeks. Sometimes the headlights would just shut off, or the stereo, or climate control settings would change at random. It was like a crazy car. Never saw anything like it. One day I just happened to have the voltage indicator option turned on in the DIC and I noticed that the voltage was fluctuating wildly - 12v to over 15v in just seconds, back and forth...then it would stop and just sit at 13.8v. I figured it was an alternator issue. But when I explained everything to the dealer they said "it's probably the battery". I couldn't understand how the battery could cause fluctuations like that, but it turned out that the battery had a bad cell. I put a new battery in and it fixed everything.
So check it out, it's a cheap and easy avenue to try.