The common answer to the question “is it okay to retire with a mortgage,” is no. But this is no true 100% of the time. There are a few exceptions to the rule and this video discusses them.
Much of the analysis revolves around safety versus alternative uses for the funds. If one’s station in retirement is such that they have excess capital and enter retirement with a strong personal balance sheet there are times when this might be appropriate.
Alternatively if the choice is a fixed mortgage versus renting this also might be appropriate. Candidly, this is a different analysis that paying off your mortgage or investing the funds and keeping a mortgage but it should not be ignored.