In California, a fence any distance 50 feet or less to a building requires a gate in the fence with a single action egress device. This question comes up when a school site wants to enclose a portion of their property (attaching the fence to a building). This is governed by Title 24, Part 9, Section1024.6 – Access to a public way.
If you are exiting through a playground or you have 50 feet or less between the fence and the building, you are going to have to put a gate in the fence and put the appropriate “crash bar” on the gate.
The issue then becomes one of supervising elementary students on the property. If a “crash bar” is on the gate, then theoretically, the student may be able to leave the property unsupervised. While a school site may be in compliance with the law by placing a “crash bar” on the gate, they may wish to follow best practices and place an alarm on the gate to alert school site staff of the student’s departure from the campus.