The intent of the "neighboring county" rule you mention is to stop people doing short "visa runs" to nearby countries (which includes Canada, Mexico, and several islands) to reset their allowed time in the US. It is not intended to impact travelers like yourself who are legitimately visiting one of those countries.
Although there is no physical exit immigration when you leave the US, the airline you are flying with notifies the US government that you have left - even when the flight is only to Canada. For your planned itinerary where you will not be returning to the US within a short period of time, you would be considered to have left the US on that date, even if the exit was only to Canada.
If you were instead to leave the US by land, again there is no physical exit immigration when you leave, however there is immigration when you enter Canada. When you pass through Canadian immigration, they notify the US that you have entered Canada - thus the US government does have a record that you left the US, and will not consider you to have overstayed.
There is a (very) small chance that something goes wrong with this process, and some people will recommend that on your next visit to the US you bring proof that you left the US within your allotted period (eg, the passport containing your entry stamp to Canada). The odds of needing this is extremely low - especially if you left by air - but there's no harm in doing so just in case.
Also keep in mind that to enter the US under the Visa Waiver Program (ie, ESTA) you will need to hold a return ticket to somewhere outside of US/Canada/Mexico. Even though you plan to fly home from Canada, you will be required to have already booked that ticket before you enter the US - having a flight booked only for the US->Canada segment is NOT sufficient to meet the VWP/ESTA requirements for a return/onward ticket. Without having a return flight already booked you will likely be denied boarding at your origin for the flight to the US.