– In the heartbreak of the moment, Kerri Walsh Jennings couldn’t think any further ahead than the next evening. Asked after Tuesday’s semifinal loss if she could come back for another Olympics in 2020, she said, “I know I can. But I don’t know if I will.’’

Walsh Jennings wanted to make sure she left the Rio Games with a bronze medal in beach volleyball, to go with the three golds she won in 2004, 2008 and 2012. In a match she called a highlight of her athletic career, she and partner April Ross got it done Wednesday, beating the Brazilian team of Larissa and Talita 2-1 at Beach Volleyball Arena on Rio’s Copacabana Beach.

In one of the most dominating runs in Olympic history, Walsh Jennings had gone 26-0 over four Summer Games before losing in Tuesday’s semifinal to Brazil’s Barbara and Agatha. Devastated by her first defeat, she ensured there would not be a second. After falling 21-17 in an uneven first set, she turned the match in the second set by chasing a ball all the way to the banners that bordered the stands, keeping it in play for a point that got the Americans rolling.

Walsh Jennings and Ross won the second set 21-17, then took the third 15-9 to give beach volleyball’s grande dame a happy — if not golden — ending in Rio. At 38, with three children and shoulders that have endured five surgeries, Walsh Jennings has not decided what comes next. All she could say for sure Wednesday was that she would cherish her bronze medal “times a million’’ compared to her golds.

“It feels like a gold,’’ she said. “The bronze medal match is the gnarliest match I’ve ever played in my career, because you get a medal or you get nothing.

“I knew last night was an anomaly. We just didn’t have it. But it’s amazing what 24 hours can do, what we are capable of doing. This is what’s possible when you stick together.’’

Should she retire, Walsh Jennings could have found no better place to call it a career. She won her fourth Olympic medal playing on one of the world’s most beautiful beaches, in the soft, fine sand and sea air meant to surround the game.

Walsh Jennings played a major role in popularizing and legitimizing beach volleyball. People still come for the vibe — and, truth be told, sometimes for the bikinis — but that alone didn’t make the sport a sure-fire hit at every Olympics. Even in London, where she played in a cold drizzle on an artificial beach built next to the prime minister’s home, hordes of bundled-up spectators came to see her and former partner Misty May-Treanor win their third Olympic gold.

The scene was much different on a balmy night in Rio, as Brazilians anticipated the gold medal match, eventually won by Germany’s Laura Ludwig and Kira Walkenhorst 21-18, 21-14 over Brazil’s Agatha and Barbara. On one side of the stadium, waves rolled up gently to meet the sand. On the other, Atlantica Avenue bustled, as it always does when Rio comes alive in the moonlight. People gathered at sidewalk cafes surrounded by potted palms, sipping caipirinhas and beer. Some beachside bars had put TVs outside for patrons to watch the Olympics, spreading the party scene at the stadium all the way up and down the beachfront.

It took a while for Walsh Jennings to get into the spirit after losing for the first time in her Olympic career. “It was harder than I thought to get up for this match,’’ she said. “I didn’t sleep.

“At some point, I’m like, ‘Stop feeling sorry for yourself. It’s an honor to have another day to fight for what you want.’ And it was a huge, huge challenge and opportunity as an athlete to come and fight for this.’’

She and Ross struggled again in Wednesday’s first set. They fell behind in the second as well, trailing 14-13 before Walsh Jennings chased down the errant ball and punched it back to Ross for a hard-fought point.

“We were having trouble, and we had to decide if we were gutsy enough to really face that down,’’ Ross said. “And Kerri was. That ball changed the match.’’

The view was the same from the other side of the net. “We made a lot of mistakes,’’ Talita said. “And then we were playing against Kerri. She never gives up.’’

Walsh Jennings said she had not spent one second thinking about what is next for her.

“I have no room in me to think about tomorrow,’’ she said. “I had to focus on being present. Our goal was to win our last match.’’