There were two systems used on the vehicles, one uses park recognition and the other uses the brake pedal in combination with park recognition. Need some more information about your car, year and model would be great.
Park Recognition: A cable connected to the switch/lock which in turn activates a cam inside the lock allowing the tumbler to be turned to "O." The cable is connected to the gear selector so when it is in park it pushes the cam in the lock assembly and allows the key to be removed.
Combination System: Incorporates the brake pedal to the above system with a twist, you must remove your foot from the brake pedal in order to remove the key. This allows the vehicle to settle against the parking pawl in the transmission (car rolls forward slightly before settling) prior to the driver exiting the vehicle to avoid injury.
Have you had any repairs to any one of the following?
1.Ignition Lock (Replaced)
2.Transmission (Removed and Reinstalled)
3.Selector rod bushings (Replaced)
Cables may be loose, they'll need to be examined to detemine the cause to your current issue.