If you do not need the money in the 401k right away and are interested in avoiding penalties on the amounts accumulated, roll over the 401k monies into a Roth IRA (your contributions and growth thereof) and a Traditional IRA (company match a d growth thereof). You can choose to take out money from the Traditional IRA not as a lump sum (penalties in addition to lots of income tax in the year of taking the distribution) but as series of equal payments over your life expectancy (no
penalty but US income tax is still due each year). Be aware that he who rides a tiger cannot dismount: if you opt for this method, you must take a distribution
every year whether you need the money or not, and the amount of the distribution must match what the IRS wants you to take exactly; excess withdrawals lead to
penalties etc. Publication 590 says
Annuity. You can receive distributions from your traditional IRA that are part of a series of substantially equal payments over your life (or your life expectancy), or over the lives (or the joint life expectancies) of you and your beneficiary, without having to pay the 10% additional tax, even if you receive such distributions before you are age 59.5. You must use an IRS-approved distribution method and you must take at least one distribution annually for this exception to apply. The “required minimum distribution method,” when used for this purpose, results in the exact amount required to be distributed, not the minimum amount.
Be aware that, depending on your country of residence/citizenship, you may
be required to close all foreign accounts within x months of return, and if
so, this stratagem will not work.