The dirty thing (at least in the UK) that the providers do is actually -charge- you for giving the unlock code -after- your contract expires.
Since an unlocked phone sells for a bit more in the pawnshops, I wanted it unlocked after my contract ran out.
Vodaphone wanted to charge me 20 pounds for what I considered to be my right to be done for free, so told them to fuck off and unlocked it myself (thought other means).
At first I wanted to fight this extra charge, but figured it would cost me way more personal time, than the actual 20 pounds it would have saved me.
But yeah, very dirty. Then again, even though they were offering me a cheaper subscription for the other phone I bought, I purposedly went with another carrier (but I don't think they lost any sleep over it; I'm assuming that most people will gladly pay the fee to get it unlocked :-( )