Sunroof sometimes works and sometimes doesn't on 2003 Volvo S60

I have a 2003 Volvo S60...ocassionally the sunroof won't it didn't work in the AM, then later I tried it and it worked, then when I went to leave the car it wouldn't close...any tips? solutions? I don't want to leave it open all night on the street:(

Asked by for the 2003 Volvo S60
Can be a faulty switch or a faulty motor. Wouldn't hurt to just try periodically to get it closed, then have a diagnosis performed at a more suitable time.