I did one once for a reason that paid off handsomely (real estate), but I'd never do it again. I felt like an indentured servant and despised the loan every moment I had it. Feeling trapped in my job sucked.
That makes sense and I worry about that. But if I had enough in a taxable account to pay it off it would just be a matter of selling ETFs and paying the tax man. Obviously I would want enough available to come up with the money.
The situation that would really hurt is if you were laid off. The loan is immediately due on separation, including termination of employment. Assuming that happens without cause, it's probably some kind of economic downturn. Which means, you'd be cashing out at a depressed market price. Good news: no taxes on a loss. Bad news: realized losses, vs. the financial and mental costs of having that loan.
That's not the likely scenario, but it's possible. It's a lot of work and anguish for some potential maximization.
Notice I don't call it optimization.
Does your employer allow in-service rollovers? Note, if you do roll over to an IRA, that has implications to your backdoor Roth, and wouldn't be eligible for rule of 55 withdrawals.