You were off on the answer. This sounds like a weak battery to me. If I leave my car in storage without a trickle charger attached, when the battery runs down, the last thing it does is roll down the windows and unlock the doors. A safety feature I assume. she was driving in a cold climate. The times it happened on the road I bet was at night with the headlights on.
This would be a good one for “Stump The Chumps.” I think Ray jumped to a conclusion without looking at all the clues. Having repaired complex electronic equipment for the past 40 years, I am least likely to suspect the computer, which is usually in an enclosure, tucked away from harm, and most likely to suspect a mechanical fault, usually from the switches, sensors, and interconnections. In this case, all the things she mentioned–the windows going down, the mirrors moving, the door locks–are all controlled by switches in the driver’s door switch panel. If water got in and caused corrosion in the switch panel, weird things could happen, since the corrosion is electrically conductive (sometimes depending on humidity). Or, if the cable that connects the door to the chassis got damaged, again intermittent shorts could cause erratic behavior. The computer is probably doing exactly what its inputs are telling it to do.
I think this is a very common problem with newer Volvo, and Ray’s answer is very close to it. Try searching for “Volvo S40 external temperature sensor problem” on the web. There is a window control wiring harness connecting the driver side door to the body of the car. The problem is corrosion in its contacts. The symptoms are: Incorrect external temperature reading, window not closing, etc. To fix it, you need to unplug the connector and clean the contacts with DeoxIT or similar electronic cleaner. Please see the TBS from Volvo included.
Which is a lot cheaper to try than buying a new computer module. :-0!! Thank goodness no Volvo dealer would ever stoop to charging a customer to replace the computer module ($,$$$) because a listener came in to the shop and suggested they might have to do that since Click & Clack suggested it, while all the Volvo dealer really did was clean the contacts.