This also happened to me and resulted in similar random power failures.This sounds random, but have you checked your terminal connections to the battery? I had one that was almost completely corroded and it would randomly shut off like that. It took me a while to notice what it was too.
If you have a lot of corrosion, be careful trying to loosen the terminal connection as the screw can get weak. Mine broke, leaving the terminal permanently stuck to the battery. Had to get a new battery and terminal.