TOKYO — On the final day of gymnastics at the Tokyo Games, Suni Lee wanted to go out with a strong finish. So did Simone Biles, who withdrew during the team final a week earlier and had not competed since.

Lee was unable to add to her total of three medals Tuesday, placing fifth in the balance beam individual final. Biles, who stepped away from competition to tend to her mental health, came back with a solid routine that earned a bronze medal. Biles had been dealing with the "twisties,'' a disconnect between the mind and body that can lead to dangerous falls.

Lee started her routine well but almost fell on a flip, fighting to stay on the beam. She also hopped sideways on her dismount and earned a score of 13.866. The St. Paul native ended her first Olympics as the all-around gold medalist and added silver in the team competition and bronze on uneven bars.

Biles looked calm and solid in her routine, getting a score of 14.000 and bringing a crowd of other athletes, Olympics officials and staff to its feet. China swept the top two medals, with Guan Chenchen taking gold and Tang Xijing earning silver.

The U.S. left Ariake Gymnastics Centre with six medals — two gold, two silver and two bronze — to finish second to Russia in the medal standings. Lee tied Lakeville swimmer Regan Smith with three medals in Tokyo, as they became the first Minnesotans to win more than two medals in a single Olympics.

"I'm really proud of myself,'' Lee said. "I'm actually super happy with the way this turned out. I didn't get a medal, but it's not the end of the world. I'm still going home with three medals. It's just amazing.''

Biles said after the competition that she was medically evaluated every day to see if she could resume. It was possible for her to do beam, she said, because she could complete a routine without twisting, which is the motion she is unable to do right now. Biles changed her dismount, taking out the twisting and doing a simpler skill.

She wasn't expecting to be cleared to compete on beam but was grateful and happy to get on the Tokyo competition floor one last time.

"It meant the world to be back out there,'' said Biles, who now has seven Olympic medals. "And I wasn't expecting to walk away with a medal. I was just going out there doing this for me.''

Lee was unhappy with Sunday's routine in the bars final, which was largely improvised after an early error. She felt the frenzy surrounding her all-around title had distracted her, leaving her less focused than she needed to be.

To avoid a repeat, Lee vowed to stay away from social media leading up to the beam final. "I just want to do the best I can,'' she said, "and end it off good.''

She started out better than she did on beam in the all-around final, when she nearly lost her balance on a wolf turn and left a second turn out of her routine. Lee got both the turns in Tuesday but nearly came off the beam at the end of a series of flips. She had to use one leg and both arms to steady herself, somehow managing not to fall.

That knocked Lee's dismount off course, too, as she finished with a hop to the side.

Lee said Biles had been talking about competing on beam after opting out of the finals in all-around, bars, vault and floor exercise because of mental health concerns. Biles revealed she had lost body awareness while in the air, making it impossible or even dangerous for her to do flips.

Biles didn't complete one of the connections in her routine and had a small hop on her double pike dismount, but those minor mistakes were beside the point. She sailed through her routine to cheers. Afterward, Biles got a big hug from Lee, then waved to the crowd.

Lee won't have much time to reflect on her Olympic achievements. She leaves next week to start college at Auburn University, where Graba's twin brother, Jeff, will be her coach.

She hasn't ruled out joining the post-Olympics tour arranged by Biles, but she said any participation would have to be scheduled so she doesn't miss classes. Lee is looking forward to a break from elite gymnastics and making the shift to NCAA competition, which isn't as intense as the elite ranks.

"That's my way of celebrating, going to college,'' Lee said.

Under new NCAA rules, athletes can benefit financially from their name, image and likeness, meaning Lee will not have to choose between competing in college and profiting from her new fame. She hasn't decided whether she will compete at this fall's world championships or pursue a berth at the 2024 Summer Olympics in Paris.

"I'm super proud of myself,'' she said. "Not many people can say they came to the Olympics for the first time and brought home three medals.

"It's so crazy how this Olympic experience has been. I'm really excited to go home and let it all sink in.''

Complete coverage from Tokyo on our Olympics page