NBA center Jason Collins recently announced he was gay in a cover story for Sports Illustrated. In other words, he "came out of the closet." This expression for revealing one's homosexuality may seem natural. Being in the closet implies hiding from the outside world, and the act of coming out of it implies the will to stop hiding. But though the closet has long been a metaphor for privacy or secrecy, its use with reference to homosexuality is relatively recent.
According to George Chauncey's comprehensive history of modern gay culture, Gay New York, the closet metaphor was not used by gay people until the 1960s. Before then, it doesn't appear anywhere "in the records of the gay movement or in the novels, diaries, or letters of gay men and lesbians."
"Coming out," however, has long been used in the gay community, but it first meant something different than it does now. "A gay man's coming out originally referred to his being formally presented to the largest collective manifestation of prewar gay society, the enormous drag balls that were patterned on the debutante and masquerade balls of the dominant culture and were regularly held in New York, Chicago, New Orleans, Baltimore, and other cities." The phrase "coming out" did not refer to coming out of hiding, but to joining into a society of peers. The phrase was borrowed from the world of debutante balls, where young women "came out" in being officially introduced to society.
The gay debutante balls were a matter of public record and often covered in the newspaper, so "coming out" within gay society often meant revealing your sexual orientation in the wider society as well, but the phrase didn't necessarily carry the implication that if you hadn't yet come out, you were keeping it a secret. There were other metaphors for the act of hiding or revealing homosexuality. Gay people could "wear a mask" or "take off the mask." A man could "wear his hair up" or "let his hair down," or "drop hairpins" that would only be recognized by other gay men.
It is unclear exactly when gay people started using the closet metaphor, but "it may have been used initially because many men who remained 'covert' thought of their homosexuality as a sort of 'skeleton in the closet.'" It may also have come from outsiders who viewed it that way. It seems that "coming out of the closet" was born as a mixture of two metaphors: a debutante proudly stepping into the arms of a community and a shocking secret being kept in hiding. Now the community is the wider community, and the secret is no longer shocking. "Coming out" is a useful phrase, but it need not imply a closet.