TJ fell back several different times and was just a punching bag during the entire sequence.
It was a lot of strikes to the head that he wasn't intelligently defending. Brains after dehydration like that face huge risk to damage.
The stoppage was in the best interests of his long term health, even if as a competitor he wanted to keep going. I think Cody looked better against TJ than TJ looked against Cejudo tonight, in terms of requiring a stoppage. TJ might have survived, but there was no indication he was going to gain a better position after another 15-30 seconds of significant blows to his head.