There's a lot of ways to do this. If you simply want to avoid derailments, you can use a power-routing turnout, and break the track at some distance from both trailing ends, so that an engine stops dead if the turnout is thrown against it. Ugly, but effective.
What I ended up doing on busy turnouts was to set up isolated sections of rail on each trailing section, and attach a train detector (I prefer the induction loop detectors from team digital - no voltage drop). Then I set up routes in JMRI which are triggered by sensor messages from those detectors. There are route controller devices (such as the SRC8) which can do the latter part for you if you don't have a computer hooked in.
Finally, I understand there's a dedicated device for tortoise motors which does all that in one package - you isolate the track, connect the wires to the device, and the device to the tortoise, and it does the turnout for you. IIRC it's called a "Hare", and it's fairly pricey at about $30 each. *