a . Please turn off the light(s) before you leave the room.
b. Please turn off the light(s) before leaving the room.
Yes, both sentences are correct. They are just Imperatives - where the subject is not stated - it is understood.
It's like: "Come here!" or "Sit down, please." - It is not necessary to say "You come here" or "You sit down, please", because you are addressing the person directly. You can onit the subject in this case.
However, you might use the subject in certain situations - for example, if you were addressing a group of people, saying "Come here." and the wrong person approached, then you might indicate another person, saying "(No) you come here." i.e. not the first (incorrect) person.
Hope that's clear...