SAN FRANCISCO — Juan Perez heard an upsetting rumor from a baseball official in the dugout during Game 5 of the World Series then hurried up the steps to the San Francisco Giants’ clubhouse to listen to the television broadcast for the news.

“I just overheard behind my back, ‘Oscar Taveras has had a car accident. He has died,’” Perez said, getting choked up as he recalled the memory still fresh in his head.

Taveras, a 22-year-old slugger for the St. Louis Cardinals who was regarded as one of the majors’ top prospects, died Sunday in a car crash in his native Dominican Republic earlier Sunday.

Taveras was driving a 2014 Chevrolet Camaro at the time of the crash on a highway between the beaches of Sosua and Cabarete in Puerto Plata, about 215 miles north of the capital of Santo Domingo, said Col. Diego Pesqueira of the Metropolitan Transportation Agency.

“He wasn’t carrying document at the time of the accident, but his body was identified by family members,” Pesqueira said.

Wiping away tears, Perez provided the biggest moment of his young career. The left fielder entered as a pinch runner in the sixth inning and broke the game open with a two-run double off the top of the center-field wall in the eighth, helping the Giants beat the Kansas City Royals 5-0 on Sunday night to take a 3-2 lead in the best-of-seven series.

Perez dedicated the double to his fallen friend and fellow countryman.

“It took me probably three innings to think over it. I knew I just had to regroup,” Perez said. “I took everything away and focused on the game.”

Perez met Taveras in 2009 and the two later played winter ball together for Aguilas Cibaenas in the Dominican Republic.

“He’s really close friend of mine,” Perez said. “I know his family pretty good, I know his mom, his dad, his brothers, we were really close. It’s a huge loss for all his family, his teammates and the people that care about him.”

Perez said he had trouble going through his routine of stretching and taking swings for about an hour. Finally, teammate Joaquin Arias came over to him and said, “Stay strong. Keep your mind strong. We got to win this game.’”

Two of Taveras’ biggest moments also happened to come against the Giants this season.

He homered against San Francisco’s Yusmeiro Petit in his major league debut on May 31. And just two weeks ago, Taveras had a game-tying solo drive in the seventh inning of Game 2 in the NL Championship Series.

“You never know what can happen in life. It’s crazy,” Perez said, shaking his head. “I can’t explain it.”