Nonresidents

Foreign citizen is treated as a non-resident alien unless he or she qualifies as a resident alien. A “US” resident is defined as a foreign citizen or national who meets either of green card tests or the substantial presence test. This definition is only for purpose of determining foreign individual’s US income tax liability. It does not for example apply for estate and gift tax purpose.

The residency rules for tax purposes are found in I.R.C. § 7701(b). Although the tax residency rules are based on the immigration laws concerning immigrants and non-immigrants, the rules define residency for tax purposes in a way that is very different from the immigration laws. Under the residency rules of the Code, any alien who is not a RESIDENT ALIEN is a NONRESIDENT ALIEN. An alien will become a RESIDENT ALIEN in one of three ways:
(1) by being admitted to the United States as, or changing status to, a Lawful Permanent Resident under the immigration laws (the Green Card test);
(2) by passing the Substantial physical Presence Test (which is a numerical formula which measures days of presence in the United States);
(3) by making what is called the “First Year Election” (a numerical formula under which an alien may pass the Substantial Presence Test one year earlier than under the normal rules).
Under these rules, even an undocumented (illegal) alien under the immigration laws who passes the Substantial Presence Test will be treated for tax purposes as a RESIDENT ALIEN.” So the Substantial Presence Test is the relevant part for most F1 or J1 holders.
In the IRS Publication 519, it says that you don’t count any day you are an F1 student towards presence in the US for the substantial presence test. However, after saying students (F1) were one of the “exempt” cases, the “exempt” status was automatically taken away after 5 years.
“You will not be an exempt individual as a student if you have been exempt as a teacher, trainee, or student for any part of more than 5 calendar years unless you establish that you do not intend to reside permanently in the United States and you have substantially complied with the requirements of your visa.”
So enjoy the Resident Alien status which allows you to claim same number of deductions as a US Citizen after five years of consecutive F1 status and claim tax treaty benefit if your country has a tax treaty with the US.

It might be possible to declare as a non-resident even after the 5 year period as long as you establish that you “do not intent to stay in the US” and you are with a “closer connection” to another country.. Perhaps you could show proof of international voting card/drivers license/property owned, etc. As long as you have not attempted to change your status, I don’t see why the non-resident status must necessarily end after 5 years. If you indeed want to continue to file as a non-resident alien, then you need to establish that “you do not intend to reside permanently in the United States and you have substantially complied with the requirements of your visa”.