I'm told that according to Mormon doctrine, a Mormon woman has to be granted entry into heaven by her Mormon husband. Assuming my impression is correct, what would happen if the husband turned from Mormonism and then died? Would the wife need to quickly remarry a Mormon before she died in order to get to heaven?
Perhaps some things should be clarified a bit here first.
First part of your question:
I'm told that according to Mormon doctrine, a Mormon woman has to be granted entry into heaven by her Mormon husband. Assuming my impression is correct, ...
Unmarried women can certainly get to heaven -- and depending on what you mean by "heaven," they don't even have to be Mormon. Remember, Mormons believe what Paul teaches about the three degrees of glory in 1 Corinthians more literally than most Christians, in that there are three main kingdoms, all of which are called "heaven."
Unmarried men and women can even obtain the highest kingdom. However, in the Doctrine and Covenants, section 131, more is revealed about this state (the celestial glory):
1 In the celestial glory there are three heavens or degrees;
2 And in order to obtain the highest, a man must enter into this order of the priesthood [meaning the new and everlasting covenant of marriage];
3 And if he does not, he cannot obtain it.
4 He may enter into the other, but that is the end of his kingdom; he cannot have an increase.
To obtain this highest glory is called exaltation. It is living like God does, being as He is.
Eternal marriage (also called a sealing), faithfully kept by both individuals, happens to be that final requirement.
I suppose then, that what you mean by "going to heaven" is actually exaltation.
So, on to the next part of your question:
... what would happen if the husband turned from Mormonism and then died?
He would face the consequences in the hereafter on his own. It's not even so much about turning from "Mormonism" at that point, but rather about breaking your covenants made in the temple, to God and to your wife, for which he would need to repent.
Would the wife need to quickly remarry a Mormon before she died in order to get to heaven?
No. Again, assuming you mean, "in order to obtain exaltation": LDS members are taught and reminded (a few sources below) that all who are faithful here will have everything and more made up after this life, and all who do not have the opportunity to be eternally married here will be able to be sealed to a faithful husband there, if that be their desire.
The eternal nature of covenants performed in the LDS temples means that whether they are made in this life or the next, they are in effect for eternity (cf. parable of the laborers in the vineyard).
Sources and further reading:
Gospel Principles, Chapter 38: Eternal Marriage "all Heavenly Father’s children who are faithful to their covenants in this life will have the opportunity to receive all the blessings of the gospel in the eternities, including the opportunity to have an eternal family."
The Eternal Blessings of Marriage (a recent General Conference address) "All things are possible to the Lord, and He keeps the promises He inspires His prophets to declare. Eternity is a long time. Have faith in those promises and live to be worthy of them so that in His time the Lord can make them come true in your life. With certainty, you will receive every promised blessing for which you are worthy."
To the Single Adult Sisters of the Church "I also recognize that not all women in the Church will have an opportunity for marriage and motherhood in mortality. But if those of you in this situation are worthy and endure faithfully, you can be assured of all blessings from a kind and loving Heavenly Father—and I emphasize all blessings. I assure you that if you have to wait even until the next life to be blessed with a choice companion, God will surely compensate you. Time is numbered only to man. God has your eternal perspective in mind."