Added automatic gate closing functionality.