I don't have a problem with this. The company may have been dumb to put this much power in one person's hands, and perhaps they got what they had coming in someone's eyes, but it doesn't excuse this behavior. If I had the only key to the server room and got fired but didn't turn in the key, I would expect retribution of some form, especially if the office had a steel door that took weeks to break down.
See, the thing is, it's not a key. It's a part of your body that unlocks the computer system. Specifically, the "key" is a series of electrical pulses in your head. Those electrical pulses belong to you because they are inside you.
To follow your analogy... the problem here is that the "key" in question belongs to YOU not the city. Why the city was ok with letting the server room be locked with YOUR key is a sign of their stupidity, but their stupidity shouldn't be YOUR problem. If you hyjacked their system so that none of THEIR keys worked properly... that's a completely separate issue to discuss.
Why is it YOUR key and not theirs? Because the key is actually a part of your brain, and a government or an employer cannot claim eminent domain over the contents of your brain, as the slippery slope induced is just barbaric beyond imagining.
When the city fired him, he took HIS key and went home.