On my two high Mountain Cottage shelf 14x32 operations (1992-2009 RIP), I used 3-1/2 x 1/8 inch high plexiglass fence. I bought 1/8"x 4x8 sheets and Lowe's cut the 3-1/2" wide strips for me on their upright panel glass cutter..I never had derailments as such but stringlinning derailment of 8-10 empty hoppers on the head end did occur at times on startup at curves. Mostly corrected by weighting first 8-10 cars with pennies.
.
In the last photo (above) just above, at the lower edge the plexiglas fence is friction-fitted between the stained window edge trim stop mold and the short blocks you see spaced along the lower track. I eventually hid the wire runs and T-strips behind the Masonite riser panels all around the layout on the two stair-stepped tracks.
I powered operations during the '90s on the five tracks with 3 pw ZWs until TMCC installed and I switched over to five 180 watt PoHos linked to TPCs. Fortunately I never had an engine or car to hit the floor. Shelves were in the Domestic CEOs kitchen-breakfast room w/ 20" high ridge.