What is a solution that's recoiled when entering to a farm?

One possible solution that's recoiled when entering a farm is a gate with automatic closing mechanism. This ensures that the gate is always closed after someone enters or exits the farm, preventing livestock from escaping and unauthorized entry. The gate can be equipped with a spring or hydraulic mechanism that recoils the gate into a closed position once pressure is released.