I didn't see the final, but I saw her in qualifying and she didn't look right then. Still excellent, but she made mistakes on a number of her performances, which suggests that she was struggling. There's every chance that she didn't feel right after the qualifying and decided to see how it went in the final. When it was obvious she was still having problems, she pulled out to give the team the best chance of winning.
We all know what a difference mental health and mental focus can make to sports people's performances. Just look at the transformation of John Stones. And let's not forget, she's not exactly young in gymnastics terms. Most of the other finalists were in their mid to late teens. She's 26. It's very difficult for anyone to keep going for that long at the very highest level.