The NHL doesn't. But the LA Kings magically managed to get out of Mike Richards' horrible contract when he was caught bringing oxi's over the border. This kind of thing was completely unprecedented at the time and depending on who you ask, was just a way they've found to circumvent the salary cap. Yet no one even talks about it anymore.
Meanwhile, if Roberto Luongo retires before the age of 42, Gary Betman has decided that the Canucks need to be punished with a cap penalty because of the length of contract that they signed Luongo to, even though it was completely legal at the time and he doesn't even play for Vancouver anymore. Makes sense, right?