BEFORE I WENT TO BED, I HAD CLOSED ALL THE WINDOWS.

2. Before I went to bed, I had closed all the windows.