It's fairly complicated, but the answer is that you won't pay US tax for selling a common stock when you're a non-resident for tax purposes, so long as it's not tied to a business you have based in the US, and as long as you're not here for 183 days or more in the past three tax years plus 31 days in the current tax year. You also have to not have a valid green card (even if you are not here) if I understand the Green Card Test right. See page 3 of publication 519 for more details.
With some exceptions, then, on page 21 of publication 519, the IRS notes:
If you were in the United States for less than
183 days during the tax year, capital gains
(other than gains listed earlier) are tax exempt
unless they are effectively connected with a
trade or business in the United States during
your tax year.
This assumes you are only discussing capital gains, and this is an ordinary stock. Mutual funds may be taxed even if you are a non-resident, dividends will be taxed even as a non-resident, and gains from sale of property, even through an REIT, will be taxed.
Some further reading: