Last summer on “Under the Dome,” the CBS hit adapted from a Stephen King novel, a caterpillar inside a miniature dome transformed into a butterfly. The climactic sequence had the audience questioning the strange symbolism. As it turns out, the significance went deeper than a fictional prophecy on the show: The cocoon was also a metaphor for the repressed sexuality of the show’s lead writer. Not that he was aware of it when he wrote those scenes.

“It was subconscious,” says Neal Baer, an executive producer of “Under the Dome,” who had finished writing the first season of the series before he came out as gay last May. As a kid growing up in Denver in the 1960s, he had collected caterpillars in mason jars and watched them change from chrysalis to butterfly.

Baer, a medical doctor who served as a longtime writer and producer on “ER” and “Law and Order: SVU,” had been with his wife for 25 years. He has a 23-year-old son. He kept his homosexuality a secret, and diverted attention by working obsessively to top each career success. “I was always worried about what was next, what the network would think, what the ratings were, do they like me,” he says. “I was fairly successful and yet I wasn’t fully satisfied.”

It might seem counterintuitive for a TV producer to worry that coming out of the closet would hurt his career in Hollywood. Some of that had to do with his traditional family structure and a generational divide, says Baer, 58 years old. But Hollywood is also inconsistent in its attitudes about homosexuality, Baer says. While it’s almost unheard of for A-list actors to be out, being gay is no big deal for writers and producers. Still, as a married, seemingly heterosexual man, the producer says he’d been privy to plenty of homophobic remarks from people behind the scenes.

He made his decision to come out after recognizing himself in books by closeted over-achievers, including “Becoming a Man,” by Paul Monette, and “The Best Little Boy in the World,” by Andrew Tobias. Baer says his wife supported him—they’re divorcing amicably–and that his son shrugged off his revelation, asking what took him so long to figure it out.

Though he spent years in denial about his own homosexuality, Baer frequently tackled related issues on screen. In 1996, when he was a writer for “ER”, the series introduced network TV’s first regular character living with HIV (played by Gloria Reuben). On “SVU,” a detective played by Ice T struggled with the discovery that his son is gay. On another episode of “SVU,” an apparently straight man has affairs with other men on “the down low,” not unlike some of the covert relationships Baer himself had.

“You’re forced to live a lie,” he says. “You’re constantly trying to figure out how to manage that lie, and it’s not pretty.”

Baer planned to discuss some of this personal history Monday night when he receives an award from the Point Foundation, which describes itself as “the nation’s largest scholarship-granting organization for lesbian, gay, bisexual, transgender and queer (LGBTQ) students of merit.”

Baer’s current projects include “If You Build it,” a documentary film that he helped produce, about a pair of educators who introduce a shop-class curriculum to a struggling school in North Carolina.

He and his fellow “Under the Dome” writers are currently working episodes six through eight (out of 13) of the second season, which premieres June 30. Monarch butterflies will again be part of the narrative, but this time they won’t be freighted with any personal symbolism for the producer.

About Speakeasy

Speakeasy is a blog covering media, entertainment, celebrity and the arts. The publication is produced by Barbara Chai and Jonathan Welsh with contributions from the Wall Street Journal staff and others. Write to us at speakeasy@wsj.com or follow us on Twitter at @WSJSpeakeasy or individually @barbarachai.