It never stops UNLESS your Tamagotchi dies before it makes a baby. Then you'll be back at generation 1. And yes, it stops counting at 99g.
Your Tamagotchi reset itself? Maybe it was running low on batteries and you selected RESET instead of DOWNLOAD on one of the screens. Also, I've heard rumors of glitches on Tamagotchis in which the DOWNLOAD option doesn't work properly. Any way, that's a bummer, sorry about that.