capital gain tax and moving out of new york

I plan to sell stocks with substantial capital gain in 2021 and have been living in New York for many years. 

 

I also plan to move out of New York and have done research on state income tax I would owe on the capital gain.  My research on capital gain tax for 2021 (due in 2022) for New York is inconclusive.

 

Assuming  I can sell stocks after I changed my permanent resident to one outside of new york, can I avoid paying New York State capital gain tax?  The same question if I move out before living X number of days in NY for 2021?

 

If I cannot avoid capital gain, does it matter whether I sell stocks before or after moving out of New York?

 

If I cannot avoid the capital gain, do I end up paying proportional tax (for example 100 days / 365 days fraction)?

 

Can anyone also recommend a tax advisor, cpa or attorney, website where I can get better information for New York taxes?  I live in queens, ny.

 

Thank you