This is a rite of passage for owners of automatic transmission cars! The bushing that holds the shift rod to the transmission lever deteriorates and the rod falls out, leaving the transmission in whatever gear it was last in.
If this happens in a safe place, you can rescue yourself by going under the left side of the car, grasping the transmission lever, and moving it all the way forward into Park. Then move it three "notches" back to get the transmission into 4. Now go to the firewall and disconnect the ball fitting on the neutral safety switch. Move the lever all the way up. Back in the car, start the engine with the parking brake on and your foot firmly on the brake pedal, as you will be starting in gear. Drive home or to a repair facility remembering not to get it a situation where you need to back up!
It's worth have a look at the bushing every once in a while. If it's showing any wear or has turned a dark brown, replace it.
Cheers,
CT