When the switch is closed it allows for the complete flow of electricity. This allows the battery to power the light source!
Open Switch Flashlight Schematic
When the switch is open the flow of electricity no longer flows continuously through the wire. Since there is no complete flow of electricity the light has no power and is now switched off.