Bad idea! Looking ahead to retirement, your objective should be to accumulate a 401K nest egg of financial assets as large as possible, and pay off your mortgage as soon as possible. You should pursue these objectives independently, not sacrifice one to obtain the other. On balance, that would be a loser, for multiple reasons.
1. Early Withdrawal Costs: Paying off a mortgage balance with a 401K balance of the same amount would not be a break-even but would generate a sizeable cash outflow because it would trigger tax payments plus a 10% early withdrawal penalty if under 59 ½. While there are exceptions to the withdrawal penalty, paying off a mortgage balance is not one of them.
2. Opportunity Cost on the Existing 401K Balance: An even larger loss from liquidating your 401K is the future earnings on the funds withdrawn. These earnings accumulate tax free until you are 70 1/2, and at that point you pay taxes only on the amounts withdrawn at your tax bracket at that time – which could be a lot lower than it is now.
3. Possible Earnings Opportunity Loss on New Contributions: If your intention is to abandon your 401K after it has been depleted, given that you are still many years from retirement, the largest loss would be the tax-deferred income you could contribute plus the tax-deferred earnings on those contributions that you would be making in future years. Your major objective should be to contribute as much as possible – I have no advice on that without knowing your circumstance – and obtain as high an earnings rate as possible. I do have some thoughts about that.
4. Maximizing Earnings on 401K Accounts: Over a period of years, the rate of return on your 401K should be well above your mortgage rate. A diversified portfolio of common stock will generate high rates of return over long periods along with high short-term variability. For example, during the period 1926-2012, the median return on the common stock of large companies over 25-year periods was 11.34%. The highest 25-year return was 17.26% while the lowest was 5.62%. Even if you consider the period starting August 2000, that experienced two bear market declines of 50%, the S&P 500 Total Return Index had an average return of 4.78%.