I got the same exact issue in my 2011 Corolla S. After driving for about 5 hours the key got stuck in the ignition slot and I had to take off the battery and lock the car manually to get some sleep. In the morning I plugged the battery and it worked. I went to the dealership 5 days after the situation, they told me the ignition cylinder was very dirty and got stuck. The mechanism is electric so when you pulled out the battery you are just releasing the cylinder "manually". They blew up some dust I believe and that was all.