Can you describe the fault further, does the motor make noise, slow down and struggles to close it or something, or does it slide as normal, and then just before it is completely shut, it goes in reverse and opens back fully again?
Mine has done that three times in the last three years I had this car, all I had to do was reset the sunroof ECU...