Truck said “Shift to Park to Start”

This morning I was driving to work, was headed towards the freeway. I was going about 40-50MPH on the streets when my truck suddenly stopped accelerating. I started freaking out and shortly after a message on dash popped up saying “Shift to Park to Start”. My truck had turned off while driving, except it was still running? I pulled over and put the truck in park, and turned my key to start the truck again. It started and I drove 45 minutes to work without it happening again. Anyone have any similar experiences or know why that happened? 2014 Ram 1500 Sport Hemi 5.7