I am a foreigner who has lived in the US for a long time, long enough to be taxed as a resident (to clarify, I was never a Permanent Resident). I moved home permanently last May. I couldn't find any instructions online or in the IRS FAQ on whether or how I have to file US taxes. Any help?
So the question is whether you are a resident alien or nonresident alien for 2016. I believe you satisfy the Substantial Presence Test, because although you don't have 183 days in 2016, when you add 1/3 of the days from 2015 and 1/6 of the days from 2014, that probably exceeds 183 days. However, since you had less than 183 days in 2016, if you can establish "closer connection to a foreign country", you can be considered a nonresident for 2016.