I'm close to retirement should I pay off my mortgage

When you’re nearing retirement, is it a better idea to pay off your mortgage or continue to invest?