I don't know the Toplight D Plus (well, I've got a couple of 4DToplight Multis, which probably share the same plastic parts, but they have an obvious on/off switch for the battery side). Electrically all you need to do is shunt (or disconnect) the standlight capacitor (easily identified by looking a bit like a coin cell battery).
I modified my Brompton stock dynamo rear light by fitting a small-value resistor (I don't remember but probably something in the region of 4.7R or so[1]) in series with a tilt switch[2], across the capacitor. I positioned the tilt switch in such a way that it closes when the light is upside-down, so to extinguish the light all you need to do is perform the first stage of the fold and wait a few seconds. This works well, as I'll usually want to stand the bike while I faff with tickets, but can also be done to good effect while riding a lift to the platform. Crucially, it meant that I didn't have to worry about waterproofing a switch.
You could use the same approach on a non-folding bike to trigger the discharge with a reed switch and magnet.
[1] The resistor is a compromise between speed of discharge and how much charge you waste when the bike goes over a bump.
[2] Ball bearing type. I decided that mercury was a bad idea around aluminium bike components. The rattle's only noticeable in practice if you pick the folded bike up and shake it.