In 20ish years, inflation is likely to have significantly reduced the value of $XXXX, it could have as little as half the purchasing power it does today. If renting, the rent is likely to increase (particularly if you move) so that you are still paying $XXXX in today's money. If repaying a mortgage, you are likely to be paying roughly $XXXX in absolute terms (depending on interest rate changes).
So yes, you are tying yourself to a risk that you will lose your house (and any difference between the outstanding loan and its sale value) if you lose your job over a certain period. However, after a certain period you are also reducing the risk that you won't be able to afford your housing costs if you lose your income.
Lenders are also more likely to consider a term extension to enable you to make more realistic payments, than a landlord is to agree to lower your rent.
That's assuming the home value has gone down in addition to losing your job or whatever. If the home has kept its value, you can probably use a line of credit to bridge while you sell the house.
How is that if I were to rent?
Interest rates can change as well but are less volatile than rents, and become less of a concern as you pay off more of your principal.