Most debts are discharged in bankruptcy, with notable exceptions being tax debt that is less than three years old, alimony and child support, and student loans. Using 401(k) or IRA funds to pay down debt that will be discharged when you file bankruptcy is like throwing money down the drain. It also hinders the purpose of a bankruptcy which is to provide a "fresh start" to those in financial trouble. Congress views retirement funds as so crucial to a fresh start after bankruptcy that most retirement funds can be exempted in bankruptcy by federal law, regardless of which states' bankruptcy exemptions apply. Retirement funds are the only asset that receives this favorable treatment under the bankruptcy code. Exhausting retirement funds to pay debts, leaving the debtor destitute in old age, is not a fresh start and is simply kicking the can of financial burden down the road.
Finally, making large withdrawals of retirement funds before filing bankruptcy can complicate the bankruptcy itself. In Kansas, those withdrawals are counted as income under the "means test" meaning that the increased income could result in a person being forced to file a chapter 13 when they would otherwise be eligible for a chapter 7. Courts are split on this issue though, with many courts saying the income taken out by early withdrawal should not be counted as income when withdrawn but when it was earned and put in the retirement account.