I did a little investigating and it turns out there are a couple ways the bulb can determine if the light switch is open or closed.
One is it can sense the capacitance between the incoming wires to the bulb. If the switch is open, there’s very little wiring between which the capacitance would exist. If the switch is closed, the bulb is still tied to the whole house wiring, and back through the main breaker to the wires coming in and wherever they may go. So the capacitance will be much higher than it is if the switch is open.
The second thing is that even though power is out, there may be a small amount of residual voltage in the lines for various reasons. If the bulb can sense a small voltage at its input terminals, it will use this as an indication that the power switch in the lamp is closed.
If you turn the power switch off on the lamp, any voltage beyond the switch back in the direction of the mains will be eliminated, and the bulb will not sense it. It will also not sense much in the way of capacitance, so it knows not to stay on using its battery back up Power if the switch is open. But it will stay on if the power goes out while the switch remains closed.
Carrying this logic one step further, it should be possible to turn the switch off and conserve battery power for the lamp during a power outage. And if you close the switch while the lamp is still plugged in, and there is a power outage, the lamp should come back on and use whatever battery power it has to light the lamp.