Hello and welcome to JustAnswer!
The key not coming out sounds like it's directly related to the problem you are having with the shifter. If the shifter doesn't completely go into park then you won't be able to remove the key. I think the mechanic said it needs a neutral safety switch, but that can't cause what you are having.
The first thing that needs to be done is repair the shifting problem. Either the shift cable is misadjusted or damaged, there is a failure in the shifter itself, or something in the transmission is preventing it from going into park. The first thing I would do is pop the cable off at the trans and shift it by hand. if it's ok then the console would need to be removed to access the shifter to inspect it and adjust the shift cable.
Once the shifter is operating correctly then you should find the key will come out again. There is an interlock cable that prevents you from removing the key if it isn't fully in park.