Here's my take, piecing together what i've seen in the NBA:
-If a player is insured, gets injured and can't play, the insurance company will pay a large portion of that salary as long as a player is out. This, I believe, is why Raef's deal when he was on portland was rumored to be so valuable: He was in the last year of his deal and isurance was covering 80% of it.
-If a player just doesn't want to play any more, i think he voids his contract. I think, then, there are specific rules about when/if he can come back to the game, so a player couldn't just "retire" and sign elsewhere. Oh, here it is:
54. What are the rules for retired players?
There's nothing binding about a player announcing his retirement. The player could still sign a new contract and continue playing (if he's not under contract), or return to his team (if he is still under contract) and resume his career.
The only exception to this is when a player is still under contract, wants to quit, and his team doesn't want to let him out of his contract. Under these circumstances the player can file for retirement with the league. The player is placed on the league's Voluntarily Retired list, forgoes his remaining salary, and cannot return to the league for one year. The latter requirement prevents players from using retirement as an underhanded way to change teams, but can be overridden with unanimous approval from all 30 teams.
Any money paid to a player is included in team salary, even if the player is no longer playing or has retired.
There is one exception whereby a player can continue to receive his salary, but the salary is not included in the team's team salary. This is when a player is forced to retire for medical reasons and a league-appointed physician confirms that he is medically unfit to continue playing. There is a waiting period of one year following the injury or illness before a team can apply for this salary cap relief. If the waiting period expires mid-season (on any date prior to the last day of the regular season), then the player's entire salary for that season is removed from the team's team salary. For example, in March 2003 the Knicks were allowed to remove Luc Longley's entire 2002-03 salary from their books (and since the luxury tax is based on the team salary as of the last day of the regular season, the Knicks avoided paying any tax on Longley's salary). This provision can also be used when a player dies while under contract.
If the player "proves the doctors wrong" and resumes his career, then his salary is returned to his team's team salary when he plays in his 10th game in any one season (including pre-season, regular season and playoff games). This allows a player to attempt to resume his career without affecting his team unless his comeback is ultimately successful. A team loses this salary cap relief even if the player later signs and plays 10 games with a different team.
Teams are not allowed to trade for disabled players and then apply for this salary cap relief. Only the team for which the player was playing when he was disabled may request this relief.
If a player retires, even for medical reasons, his team does not receive a salary cap exception to acquire a replacement player.
So if a player just said "i have enough money, i can't take the travel and physical/mental stress anymore, i'm done" he could retire, get no more additional money, and the only part that would count against the cap is what he already got.
If KG blew out a knee tomorrow and just decided it wouldn't allow him to play again, and doctors agreeed, (knocking heavily on wood), then in exactly one year, his remaining salary would get wiped from the books (so only about half of his stated salary would count against the cap). However, KG would still get his full salary in real money, most likely from an insurance company. If this happened to somebody like Q richardson or Eddy Curry, the same thing would happen, but the TEAM would still have to pay real money (while getting salary cap relief) since i think those were two players no one would insure.