Remember money in retirement plans is protected from bankruptcy. If you think you are going to file BK, leave the money in the 401K or IRA. Once it becomes cash, it's cash.
If you leave employment, the existing loan will become due. If you don't pay it in 60 days, it becomes a distribution which means you owe 10% penalty and standard income tax.
Sorry but its a RARE financial hardship (like I have an untreated disease that will kill me here in a little bit kind of rare) that makes it worth taking the hit by drawing out a 401K early. (Treated as additional income that is taxed and THEN an additional 10% penalty). Hard financial times, get a second, third and fourth job, I did. Bust your butt, and cut your expenses before tanking your retirement funds like that.
If you terminate employment, you have 60 days to pay back the remainder of the loan. After that, the remaining loan balance is automatically reclassified as an early distribution and you pay the income tax and penalty on that. The remainder of your 401(k) account is yours to do with as you wish. Same thing will apply if you take it out.
If you leave, you can withdraw the rest of the money, but you'd have to pay income tax plus a 10% penalty on whatever you withdrew plus anything not paid back.
You must pay 401-k loans within 60 days of leaving your employer, otherwise it becomes taxable.
If you withdraw what's left or d not pay back the loan, the withdrawals are both considered early withdrawals and you pay income tax plus a 10% penalty.