let alone makes a stopover, you still are subject to US customs inspection.
Another US peculiarity, which is a major problem for many people daily.
Making it worse, the US considers Canada and Mexico part of the US for visa purposes.
So a 4-month visit to Canada, transiting the US both ways, is considered a 4-month stay in the US and so ineligible for ESTA and needing a full visa with interview just to transit.
Here is some help to avoid US transit: