"Mind" is followed by an "-ing" form when it is followed by a verb. This is a strict rule.
So we must proceed like this:
Would you mind having...?
"Explain" works like this: explain something to somebody.
Can you explain the rules to me?
Now we have to combine the two rules, remembering "mind" needs a verb in present participle, and "explain" needs "to + person":
Would you mind explaining to me why you didn't show up last night?
Is the winner. The way we link verbs to other verbs, or use them with objects is commonly called Verb Patterns). Take a look at the basic article linked before which summarises the different types.
In OP's first example there's an implied your (or you) after mind...
1: “Do you mind [your] closing the window?”
(or)
2: “Do you mind [you] closing the window?”
...corresponding to...
3: “Do you mind my closing the window?”
4: “Do you mind me closing the window?”
Note that 4 has becoming increasingly common over recent decades, particularly in BrE. Syntactically, everything after the word mind is a noun phrase. As a general principle, using the possessive form (my, your, his) in such contexts is "dated", but it survives more in "Do you mind [NP]" because it's a relatively formal construction anyway (and people tend to stick to older forms in formal contexts).
Also note that we tend not to use mind in this sense unless it's part of a question ("Does your husband mind our/us meeting like this?") or a negation ("I don't mind your/you phoning so late at night"). That's to say although "I mind your/you smoking while I'm eating" is grammatically "valid", most native speakers simply wouldn't say it.
Let's consider the more general context and introduce another syntactically similar verb...
5: I like ice-cream
6: I like your kissing me
7: I like you kissing me
8: I don't mind your kissing me
9: I don't mind you kissing me
10: He doesn't mind our meeting like this
11: He doesn't mind us meeting like this
I've included 5 there as a clearer example of a simple "noun phrase". Although currently most native speakers (particularly, AmE) still use possessive my in OP's example (because semantically as well as grammatically, it's a formal usage), they're much more likely to use the accusative/object forms in 7/9/11 above, rather than 6/8/10.
In light of this ongoing shift away from the possessive in constructions of this general form, I think it's probably more useful to interpret OP's first sentence as a "cut-down" version of my example 2, and the second one as a slightly dated version of my example 4. You'll still encounter the possessive in various contexts, but I don't think you ever need to produce it yourself.
EDIT: In the interests of "balance", it's well worth considering StoneyB's answer to a very closely-related question, where the final "advice to learners" paragraph recommends using the possessive. I'm not going to disagree with that, provided you wish to master "formal" usage, and bearing in mind that it would be slightly "dated, odd" to use the possessive in informal contexts such as example 6 above.
Best Answer
Only the first sentence is grammatical, but the second one would be with a slight change:
Note that in the second version, opened can also be used.
A more direct way of asking this is simply:
Generally speaking, the last version is the most common.