I was divorced for 3 years when I realized, and it was after an 11 year marriage to a woman. First, I found out that I was actually attracted to men, then shortly after I realized I was a woman.
I don't think it was possible for me to come out of my closets, to myself, until after I had adequate space after my relationship ended. I was too deep in my performance as a straight man and being in the relationship was an addiction in itself.