Turn off the lights when you leave the room.

Literal

Room [object-を] exit [when-ときに] [topic-は] lights [object-を] turn-off [imperative-なさい].

Uses the polite imperative ~なさい to deliver the instruction as a directive rather than a request. The form reflects the speaker's authority — likely a parent or teacher addressing a child or student.