The setup uses a "train sensor", a circuit controlled rail signal and a chain signal to do its thing.
Core setup
Core setup BP
From that core setup we can, for example, design an outpost that only allows trains actually visiting it to use it:
Outpost
Or we can make sure that trains that use a station complex to turn around use the designated bypass-lane instead of the stations:
Stacker + stations
I've not really looked at other applications but it's probably possible to combine this with disabling stations to make something interesting.