Agreed. Also, even if Canada were to shut down all NORAD radars and command posts on Canadian territory and to kick out every US soldier and to tear up all agreements with the US,
Canadian cities and important Canadian infrastructure within 100 miles of the US border (i.e.,
most Canadian population and infrastructure) would probably get nuked in a nuclear war just so that the US cannot rely on those resources during the US's recovery from the attack.
A large nuclear exchange between great powers (and currently there are 3 great powers, the US, China and Russia) would be followed by the use of conventional military forces. E.g., The US would try to capture and hold major ports of the power or powers that attacked it because holding ports is a very effective way of denying the power the ability to deploy its own conventional forces outside its own territory and the ability to rebuild its nuclear stockpile. Military planners in the power or powers that planned the nuclear strike on the US would know that and consequently would realize that it is essential to slow down the US's recovery from the strike as long as possible.
In summary, if the US ever endures a large nuclear strike, it is very likely that Canada gets nuked, too. Canada's kicking out the US military and declaring the US to be its enemy might cause a minor reduction in intensity of the nuclear attack on Canada, but is very unlikely prevent it altogether.
Yes, Switzerland was able to avoid any attacks from the UK, the US or the USSR during WWII despite sharing a border with Germany, but that was probably near thing. Also, Switzerland was very hard for Germany to invade because of how mountainous it is; in contrast, most of the cities and infra in Southern Canada is separated from the US by nothing but plains. Also, Switzerland invests very heavily in its military capacity, e.g., every Swiss male must do military service, e.g., every bridge in Switzerland is engineered to be easy for Swiss forces to blow up.