Washington CNN  — 

Republican presidential contender Sen. Ted Cruz apologized for an ill-timed joke about Vice President Joe Biden Wednesday night.

While speaking at a GOP dinner in Michigan on Wednesday, Cruz delivered an oft-told stump speech line poking fun at Biden, mentioning his name and then saying, “You know the nice thing? You don’t need a punchline,” according to the Detroit News.

“Honestly, it works,” Cruz said, according to the news report. “The next party you’re at, just walk up to someone and say, ‘Vice President Joe Biden’ and just close your mouth. They will crack up laughing.”

While the line is often well-received on his campaign trail, this time it fell flat. Biden’s son, Beau, passed away from brain cancer on Saturday.

RELATED: Ted Cruz ‘imagines’ 2016 presidency in Liberty speech

Cruz took to Facebook and Twitter to issue an apology.

“It was a mistake to use an old joke about Joe Biden during his time of grief, and I sincerely apologize. The loss of his son is heartbreaking and tragic, and our prayers are very much with the Vice President and his family,” Cruz wrote.

Beau Biden’s funeral will be held on Saturday in Dover, Delaware, where he served as the state attorney general. President Barack Obama is scheduled to deliver his eulogy.