I had the same happen to me (once). I was flying through a thunderstorm and all of a sudden I lost all power and electricity. The flight surfaces were working though so I attempted the “Gimli Glider” maneuver. My skills were not up to it and I ended up crashing before reaching the nearest airport. I never figured out why I lost power. I had been playing around with the FMS and thought I might have overloaded MSFS with instructions or maybe a lightning strike had fried my electronics.