It could be the CDI, but, is the bike getting too hot? Check coolant & water pump. BUT my money is on a bad coil. When it shuts down, touch the coil and see if its over heated. When a bad coil gets too hot, its because the wiring coil inside is shorting across from one winding to another. (Just a note-coils all work the same-almost any 12 volt coil will work if wired right-even a cheap China coil that's set up the same with number of connections.) And, another problem area is the voltage Rectifier. I fixed a 110 atv this week that people had been fighting for a year or so. It would start, run good awhile, then run bad, shut off. The problem, Rectifier getting hot as it was shorting out internally.
Spark wise, these things all work the same. Trigger coil (my name for it) sends a small voltage signal to the CDI, every time that the flywheel turns to the position where a magnet in it passes under the trigger coil.
Then, the CDI sends a larger voltage to the coil, which then sends a very large voltage to the spark plug, which then fires.
With and OHMS meter, you can check out the "TRIGGER" coil.
All of todays engines use this same principal, even cars on the road. There its called a "Crank Position Sensor". This system replaces the old "Contact Points", that we used to work with to clean and reset. They made contact once for every cylinder a motor had.
Hope all this helps.