Yes, it's called mortgage life insurance, and you can buy a policy on the life of your spouse that will pay out a death benefit when your spouse dies during the life of the policy.
That way, you have money to pay off the remaining balance on your mortgage and can remain in the home you shared with your spouse should your spouse die.
Learn more about buying life insurance that pays off mortgage if spouse dies.