It's not when they retire, it's when they sign the contract
If a player signs a contract before his 35th birthday, regardless of length, if he choses to retire, the club is obsolved of the cap hit.
If the deal is signed after the player's 35 birthday, the cap hit stays regardless of retirement/demotion/or release/buyout (the only exception is a long term injury clause)
The Canucks couldn't waive them to get rid of them, they would have to voluntarily retire since NHL contracts are guaranteed
The trick with these long deals it to have the remaining few years pay so little, that the player would chose to retire rather than play since they would be at an age where they would be thinking retirement anyways
This 12 year deal is really a 9 year deal (Sedins will be 37) if they retire at that point. The last 3 years will be at 1 million per, so the deal really is 9 years and 60 million, (average 6.66 per year) but stretching it over 12 years lowers the cap to a very friendly 5.25