Dude, come on. It happens all the time. With players, coaches etc.
When a team fires a coach, they let him talk to other teams (which wouldn't be the case if he was still working for them, obviously).
The guy is sitting at home, collecting his paychecks and if a good offer comes by, he calls back his former the team, saying he's willing to terminate the contract. Team obviously agree because they don't have to pay him anymore. I believe it might even be automatic, like there's a clause in the contract that says the contract is voided if the coach signs with another team after being fired.
They have plenty of clauses like that in these contracts. I believe the guys are not allowed to work for sports media without terminating the contract, too.
Gallant isn't likely to be sitting at home for the next two years.
I don't understand why you assume these contracts are like, 100% unbreakable under no circumstances??