The following is deduced from looking at the train and its reactions on the tiles. (I know about electronics)
It seem that if no reflections are detected within approximtely 1 second, then the train switches off. In normal driving, the gray track parts reflect light on/off. But if you lift the train, then it sees no alternating reflections - and stops.
The colored tiles:
Looking at the bottom of the DUPLO train, you see a tiny window. Inside this is a 3 color LED diode. It looks as if the diode is cycling through the colors black (actually off) - red, blue, green, cyan, magenta, yellow, white.
These are the colors possible if each diode is just switched on or off
(I dont know if it uses brightness modulation - but I think not)
In the window is also some light detector, measuring the amount of reflected light. So a red tile will reflect a lot when the red LED is on, but a green tile will reflect very little when the red is on.
This provides 7 possible tiles for the coding.