I've experienced an "all of a sudden, dead" engine three times. Twice, the mag had gotten wet during operation, and one time was a new engine, ridden maybe 10 times, and the mag just died, for no reason at all.
If there is electrical difficulties, in my experience, it's the mag. Cheap and easy fix to replace anyways, so it's a good place to start. (Just my opinion, not professional)