The power window controller takes care of lifting the windows and the sunroof one by one. It senses the required current and decides to stop the power when the begin or end position is reached, thus automatically shutting off. It uses series resistors of a quite low value to sense the current. Obviously the relays that do the actual power switching sometimes do fail and repairs may be required.