Out actor Sean Hayes, who is best known for playing Jack McFarland on the NBC comedy Will & Grace, has said that he was taught to keep his sexuality a secret.

In a cover interview with UK LGBT glossy Attitude, Hayes discussed why he stayed closeted during the show's initial run.

Hayes, whose campy Will & Grace character is gay, came out in 2010, roughly 12 years after the show debuted on NBC.

Hayes said that he was “too scared” to come out earlier.

“It was a scary time,” Hayes said. “We got death threats, [people] could find out where I lived, and I was playing a gay character in a big hit show.”

“I was too scared. I wasn't looking to be an activist of any kind. I didn't have the courage and the strength at such a young age to speak on behalf of the gay community.”

“We were taught by society in the seventies and eighties that being gay was an awful thing … I was taught to keep it a secret. I was taught to be ashamed of it.”

“Time's up in a different way for the gay community to show the world that we're okay with ourselves and I'm done taking care of [other people's] awkwardness around it,” he added.

In 2014, Hayes married longtime partner Scott Icenogle, a music producer.