If you really planning to leave the US and move elsewhere (retirement or work or whatever) in a permanent way (not as a temporary move as a US citizen or greencard holder) then you need to look at your life as divided into two separate time periods. Some investments will work well in one and not the other. You will need to think about how to transition investments that aren't suitable in the second, post US, time period from the first. Sometimes, investments that aren't suitable in the second time period are still worthwhile to hold even if they don't make sense post-US because the benefits are high enough and you will be in the US long enough.
Taxable accounts: When you return to Spain you will use the US-Spain tax treaty to deal with interest and dividends from these accounts. You will owe capital gains tax to Spain in whatever way they are taxed there. You may still owe Spanish tax on the interest and dividends but you should get credit for the US tax paid (check Spanish tax laws).
Retirement accounts (401k/IRA/etc.): These should be treated as retirement accounts under the US-Spain tax treaty. They are listed under the "Pensions and Annuities"
column of the tables. You will have figure out the Spanish taxes on these as well. Also, you will still be subject the to 10% early withdrawal penalty if you try to withdraw before age 59.5 as usual.
Personally, I used these retirements accounts since the company match plus the immediate tax savings was huge. My plan with these is to hold them until I am 59.5 to avoid the 10% early withdrawal penalty. I will withdraw them when I am in a tax situation outside the US where they will be taxed at 0% by the US and 0% by the country I am residing in. I do take the risk that I will die in the 6 or so years that I am outside the US but holding the accounts.
Roth type accounts: It's important to check these type of accounts for validity in Spain. Some countries don't recognize these as valid retirement accounts and you will owe taxes on them as if they were regular investment accounts. That was the case for my home country, Canada, when these types of accounts were first introduced. That has since changed but it might still apply for other countries. You need to do your research.
Social Security: You should be able to collect SS while outside of the US and even without a greencard/citizenship. You need 40 quarters of "substantial" work (10 years). They will pay out to most countries of the world.
https://www.ssa.gov/international/Agree ... spain.html
Estate Tax: This is the real killer item for holding US accounts when you are not a US tax resident. The estate tax will take a large chunk (up to 40%) of the assets you have that are US situs (retirement accounts, brokerage accounts, etc.). This could leave you or your wife in a bad place financially. This is the biggest reason that you need to have a plan to transition your assets out of the US after you leave. Nice easy summary -
https://www2.deloitte.com/content/dam/D ... aliens.pdf
Expatriation: This is the process you will need to go through when you leave the US if you are abandoning a greencard or giving up citizenship. If you don't explicitly do this as a greencard holder then it will happen at some point because of lack of presence in the US but the timing will not be of your choosing.
The current laws will apply a punitive exit tax on people who abandon their greencard with over US$2 million in assets and that dollar value is fixed and not adjusted for inflation. The law will slowly ensnare more people as inflation makes the cutoff amount effectively lower. A couple can get out with twice that (each has the $2M limit) and with some work can get out with $9.5M under current laws. See -
viewtopic.php?f=1&t=213098&p=3401794&hi ... n#p3399002
The current law has only been in force since 2008 and there have been a number of other expatriation laws over the years. The current law may not be the one in force when you expatriate but I would count on the law getting only harsher and more punitive.
I really recommend the
blog written by a US international tax/expatriation lawyer Phil Hodgen. I have learned a lot from it, he writes well, and explains in non-lawyer terms.
This is all really complex and there are not a lot of people who understand all the parts well. You will likely have to become your own "general contractor" for this and may need to hire one or more sub-contractors for individual parts.
It’s not just that facts don’t seem to matter anymore. It’s that it doesn’t seem to matter that facts don’t matter.