Sell the U.S. stocks before you die, and don't stay in the U.S. for more than 183 days that year. https://www.forbes.com/sites/greats.../how-to-save-u-s-taxes-for-nonresident-aliens
May not work in many cases. Get killed in accident. Or suddenly die in heart attack without warning. Nobody can know in advance when he is going to die. Maybe cancer patients who have been forewarned by doctor but in many cases, we won't know.
Of course you usually won't know exactly when you will die. It sounds like you might want to contact a tax accountant or a lawyer specializing in estates.
It depends how much you have in US assets relative to your entire estate and where you reside. For Canadians there's a tax-treaty which includes a unified credit pro-rated based on the ratio of US assets to the total worldwide estate. The following site provides an example: https://www.taxtips.ca/personaltax/usestatetax.htm So for a $12M estate where 25% ($3M) is in US assets the total estate tax due is $41K which is insignificant compared to the overall value. Your mileage will vary but in this case it makes a lot of sense to keep your US assets as a small percentage of your overall assets thereby keeping any US estate tax to a minimum. Definitely something to be aware of and plan accordingly. However you look at it it will be messy and will involve lawyers, etc. so there will expenses and/or tax involved.