When he left the room, he turned off the lights.

Literal

Room [object-を] exit [when-とき], he [topic-は] electricity [object-を] turned-off.

A simple narrative use of ~とき linking two sequential events. The dictionary form 出る before とき is used even though both events are past — the focus is on the moment of departure as the temporal frame.