Upvote:5
You're considered to have left the US at the recorded departure time of your flight which leaves the US to any other country. You need to depart within the 90 days stay granted when you originally entered the US.
The 90 day clock everyone refers to begins when you receive your admitted stamp on entry to the US, and it's only relevant if you re-enter the US before the 90 days ends, but have only traveled to Canada, Mexico or the named Caribbean islands. When you do this, you're readmitted under the previous admission and must depart before the end of the original 90 day period, again to any country.
If you travel elsewhere, or you remain outside the US past the end of the original 90 days, then return to the US, then if you are admitted it will start a new 90 day period. But if you return too soon after the first 90 day period ended, you will attract the attention of CBP officers and likely be questioned more closely about your travel plans.
The purpose of this is simply to prevent visa runs, where someone exits the US for a few days and then returns, in order to live or work in the US without having been admitted for that purpose.
Note well that this can affect your travel plans if you need to transit the US in order to return home. The US does not have sterile transit areas; you must be cleared through immigration even to transit.