As others have said, the issue sounds like more one of "keeping significant others at the table" than keeping women at the table. We've had three regular woman players in our current group. Two of them were spouses of another player in the group and got bored and dropped out. One of them came to the game directly — she knew a friend was playing and asked to join — and she was one of our most committed players until moving to another city.
I agree. Generally speaking, keeping relatives interested in the game can be a fight against windmills and in many cases is not really worth the effort. Because interests vary and you don't want to "force" a player to stay in your group who only joined just because he/she wanted to be polite or even genuinely give it a try. My own sister, who loved online free-form-RP and had a sweet spot for dragons and fantasy didn't hook up with D&D. Too many rules and restrictions and mechanics for her taste. And that's okay.
There are definitely things groups of men can do to be hostile to women, so look that stuff up and stop doing it. Excessive man-splaining, constant interruptions, misogynist humor, rape jokes, etc. Not saying you do that at your table, but if you do, now is a good time to stop! It also helps, as a DM, to make sure you have lots of women as interesting NPCs in your world. The first time I played D&D as an adult, with a woman in the group, I realized that all of the major NPCs in the adventure were either men or "merchant's wife." I've started rolling the gender for NPCs.
Take an opportunity to be sensitive to your whole group. Don't just ask the one woman player in your group, "are there any things you don't like or are uncomfortable with?" Ask everybody. We did this with when running a horror game: we e-mailed the whole group and said, "this is horror, it can get ugly, but there are any lines you'd rather not cross? feel free to reply privately." Both men and women responded privately with requests.
So many yesses! Usually, no two women are alike, but your point could easily be renamed "common courtsey" and "being open minded and sensitive to the needs of others". If you would ask me, as a die-hard TTRPG loving woman, about the points which really annoyed me in my roleplaying carreer, I would name some of your abovementioned hostilities.
Getting interrupted sucks. And makes you angry. Especially when your interruptor then continues with a minutes-long monologue about things he deems important.And unfortunately, many of us are conditioned to be "nice" enough to not complain. It really took me years to voice my frustration on getting interrupted all too often.
Man-splaining... happened excessively with a guy we kicked out a few years ago. Luckily, he tried to man-splain not only for me, but for my fellow male players as well. And it turned out that we all knew more about the matters he was trying to tell us all about. Don't try to educate a 10+ years D&D veteran on how deadly a barbarian/frenzied zerker can be if you don't really understand the rules or the math. Also, don't try to educate a japanophile on japanese culture. Or a student of social sciences on what "victim blaming" means.
And while I don't mind (and even start) sexual innuendo and flirty jokes, this doesn't mean you should assume that it is okay for every player. Also agreed on rape jokes as a no-go. I don't make castration jokes either, eh?
Mature, or possibly disturbing themes should generally be consented by the whole group. We recently played an all-evil diabolist campaign and had to discuss on how to handle some of the more obvious practices of devil worshipping, like torture, sacrifice or gory violence in a way that none of our players would feel disturbed or freaked out. When handling harder themes in a campaign, in my experience, using reasonable (mature) consequences does help a lot.
And for the women NPC: Yep. But in most cases, the reason for "too many males", at least in significant roles, stems from the fact that many DMs are guys and tend to display their own gender as "default". I realized that I did the same when I first GMed a standalone adventure and almost all my important NPC were women. Unfortunately, many modules/Settings out there are written by men who don't know their own hidden bias and so write 70-90% male (and also often human) NPC into their world. Without even knowing it. Or having any ill intent. I once made the experiment and asked one of my GMs whether he knew that almost all his NPC were guys and he was shocked when he realized it. And yep, he tried to balance his NPC afterwards
Another pet peeve of mine that can be very upsetting is "Setting sexism". Because of "medieval realism". This can result in pretty annoying situations for players of female PCs who are then constantly questioned, harassed or belittled. Just don't do that. Not that you should fear incorporating *some* societies or people into your world who are biased, prejudiced or even hostile towards members of a certain gender, age, race or social group. But 1) it shouldn't be the norm that everyone and their dad is a misogynistic pig and 2) try to even out the biases. Have a matriarchal and a partiarchal society next to each other (which might be in a perpetual feud). Have one region where being a halfling makes you legendary descendants of a god, just to be viewed as utterly unworthy by a country where height means everything. And, most important, discuss the consequences such societies and stigmatas can have on your PCs and NPCs.