Can't remove ignition key when engine is warm

2000 Volvo S70, 177K - This car is new to me, and shortly after purchasing it, I began having difficulty removing the ignition key when arriving at a destination. With the transmission in Park, and the engine shut off, the key just won’t come out. Then again, sometimes there’s no problem at all. Oddly, the problem seems to correlate with the cabin/engine temp. If I allow the car to cool off, then go back to it in a half hour, the key will usually come right out. Same thing with short trips. I’m fortunate so far that I’ve not been in any high crime areas where leaving the key would be risky; but I will need to solve this eventually.

I understand that there’s a safety switch/sensor that ensures the vehicle is in Park before the key can be removed, and I’ve tried being a bit more “forceful” in shifting to P, but that doesn’t seem to help. I’ll be taking this to my mechanic anyway for a state safety inspection followup; are there any hints I can give him if I can’t figure it out myself?

Is the temperature factor suggestive that the problem is in the transmission sensor? I’d prefer that the issue be a sensor or adjustment rather than in the ignition switch just to avoid the re-keying mess. Thoughts?

Clarify one thing. If you don’t put the car in park, then the key won’t come out, but that is because you can’t turn the key fully to the “Off” position. It remains one click up from that (often the ACC position) and it is in that position that you can’t remove the key. So during these times when you can’t remove the key, is the ignition lock cylinder still stuck up one position? Or does it move full to off but the lock cylinder still won’t let go of the key?

Sorry to be so late getting back. The key turns back fully to the off position, where it should come out. It is not getting stuck partially on.

FWIW, I’ve had pretty good luck lately, with the key coming out more often than not, and irrespective of the temperature. I keep trying to notice any subtle contributing factors; but so far it seems random.