Ian McKellen is apologizing after making some controversial comments about Bryan Singer and Kevin Spacey, two men who have been accused of sexual misconduct in Hollywood.

McKellen took to Twitter on Saturday to say he regrets his "careless remarks."

"As part of an extended podcast recently, I suggested that if closeted people were instead open about their sexuality they wouldn’t abuse others. That, of course, is wrong," he wrote. "My intention was to encourage the LGBT audience I was addressing, to be proud and open about their sexuality. In doing so, my point was clumsily expressed. I would never, ever trivialise or condone abuse of any kind."

During a live recording of the #QueerAF podcast, the actor noted that the director and actor weren't out during the time the alleged incidents occurred, and then he made a puzzling statement citing that as the cause of their alleged behavior.

"Most of them were in the closet. Hence, all their problems as people and their relationship with other people," he said. "If they had been able to be open about themselves and their desires, they wouldn’t have started abusing people in the way they’ve been accused."

He followed up his shocking comment by adding that whether those accused of abuse should be forced to stop working is "debatable."

"I think that's rather up to the public," he said. "Do you want to see someone who's been accused of something that you don't approve of? Do you ever want to see them again? If the answer is no, you won't buy a ticket, you won't turn on the television. But there may be others for whom that's not a consideration."

McKellen worked with Singer on the "X-Men" movies and the 1998 film "Apt Pupil." He worked with Spacey when Spacey served as the artistic director of The Old Vic theatre.

Most recently, four men accused Singer of sexual misconduct in a story in The Atlantic. Two of the men say they were underage at the time of the incidents. Singer has disputed the allegations, saying that the story was written by "a homophobic journalist."

And more than a dozen men – including five who said they were teens at the time – have come forward to allege Spacey sexually harassed, assaulted or attempted to rape them. Spacey has denied all accusations of nonconsensual sex.

McKellen also seemed to joke on the podcast, which was recorded during National Student Pride 2019, that he wondered if accusations against him will surface.

"Frankly, I"m waiting for someone to accuse me of something," he said to laughs from the crowd. "And me wondering if they're not telling the truth and me having forgotten."

More:Exclusive first look: Helen Mirren, Ian McKellen get twisty for thriller 'The Good Liar'

Photos::Kevin Spacey arraigned on sex-crime charge on Nantucket