2000 Subaru Outback stops dead


While driving, the engine starts to cough & choke, the tach waves around, and sometimes the engine stops dead and all electrics go out. I coast to the side of the road, say bad words. Usually I can start it again after waiting 10 -30 min. What’s happening? I have been blaming bad gas &/or clogged filter, but does that explain electric cut out?