The ignition switch on my BMW has a number of interlocks - nanny state rules.
One is you can't remove the key without putting the car in neutral or park.
Just recently, on a couple of occasions, I've not been able to remove the key. Both times when shopping - so not (obviously) wanting to leave the car with the keys in it, drove home. Where the key then came out normally.
Basically it's not turning to the fully off position. But I'm not sure what's stopping it - my guess is the interlock from the gearlever. Anyone had this sort of system apart and know how it works? A complete new lock and switch assembly likely costs as much as a new car - by the time it's been programmed in. ;-)
It's quite easy to remove the actual lock barrel itself - if I knew what to look for inside.