I think you can probably get away with not using a particle at all (dropped particles is fairly common in Kansai, even を) but if you do that the subject becomes yourself, rather than night. "I close the window at night" rather than "at night I close the window."
Ni would be correct here, but changes the emphasis of the sentence. Here, wa is used to draw emphasis on the fact that you close the window /at night/, implying it is open at other times. Using ni removes this contrasting aspect to the sentence.