Flicking the switch on a molecular gate