Ray Allen won championships in Boston and Miami, made one of the most memorable shots in NBA Finals history and has more 3-pointers than anyone who ever played in the league.

More than two years after his last game, he’s decided that was enough.

Allen announced his retirement on Tuesday in a post on The Players’ Tribune website. Allen spent 18 seasons in the league with Milwaukee, Seattle, the Celtics and the Heat, averaging 18.9 points in 1,300 regular-season games and appearing in 10 All-Star Games.

“I write this to you today as a 41-year-old man who is retiring from the game,” Allen said in his post, which was in the form of a letter to his younger self. “I write to you as a man who is completely at peace with himself.”

NBA Commissioner Adam Silver called Allen “an extraordinary player.”

“On behalf of the NBA family, I want to thank him for being a wonderful ambassador for the game,” Silver said.

Allen entertained thoughts about a comeback over the last two years and had plenty of opportunities from title-contending teams. But nothing ever lured him back, although the door always remained a tiny bit open – until now.

“Basketball will take you far away from that school yard,” Allen wrote. “You will become far more than just a basketball player. You’ll get to act in movies. You’ll travel the world. You will become a husband, and the father of five amazing children.”

Allen starred in the 1998 Spike Lee film “He Got Game.” He portrayed Jesus Shuttlesworth, a top-ranked basketball prospect, whose father (played by Denzel Washington) is in prison for killing his wife.

“We have had many great players through the years, but Ray is probably the No. 1 name brand we’ve had,” said Jim Calhoun, who coached Allen at UConn from 1993-96. “We, at UConn, can all be proud of what he accomplished here and the greatness that he achieved when he went on to the NBA.”

On the court, teammates and coaches raved about Allen’s famed work ethic and commitment to fitness – which now takes a different form, after he and his wife, Shannon, recently opened an organic fast-casual restaurant in Miami. Allen was almost always on the floor for a workout three hours before games, shooting on some occasions before the arena lights were even turned on.

“If you had to cut out somebody and make a poster child for these young guys to look up to, that is a guy I would put in front of them,” said Memphis coach David Fizdale, an assistant with Miami during Allen’s time there. “This is how you become a great player. This is how you become a great person in your community.”

Allen had the record for 3-pointers in a season for seven years, his mark of 269 standing until Stephen Curry of Golden State made 272 in 2012-13 – a record Curry has topped twice.

“The greatest shooter to play the game,” Curry wrote in a tweet Tuesday, congratulating Allen on his career.

In all, Allen made 2,973 3-pointers in regular-season games, which doesn’t even count the one that was his most unforgettable.

His 3-pointer from the right corner with 5.2 seconds left in Game 6 of the 2013 NBA Finals for Miami sent the Heat to overtime against the Spurs in a win-or-else game, and helped them go on to win the title in seven games. Chris Bosh got an offensive rebound and passed to Allen, who was backtracking toward the corner.

Allen, without even needing to look down to ensure that he was behind the line, elevated over Tony Parker and connected to tie the game – even as arena workers kneeled around the court, holding the rope that they presumed they would soon be called upon to cordon things off for the Spurs’ championship celebration.

On his way back to the bench to prepare for overtime, Allen gestured to those workers, shouting to put the rope away.

“It’s going to be a shot that I’m going to remember for a long time,” Allen said that night. “There’s a lot of shots that I’ve made in my career, but this will go high up in the ranks.”