ok seen as none of the other guys on here havent replied i will take a stab at theis for you .. the roof electric motor probably works somewhat like the elec windows .i.e. when you close the window the window moves up the guies and when it meets the sill there is some resistance so the motor stops .i recon whats happening with your sunroof is that it is meeting resistance as it slides along its guide rails and thinking its closed but then as it is not closed it realizes it has not hit final stop position and reopens .this is a safety feature in case for eg. a child or stupid adult got something stuck in the sunroof whilst it was being closed .. soo i would make sure the rails were clean and lubricated with special raiil lubricant i.e some pledge aerosol furniture polish may help in absense of the actual real deal .and make sure there is no rust. or partiulate matter stuck and blocking the rails both of the door and rails ..Caution make sure the door doesent close whilst you are working on the rails by disconnecting the battery wnen its in the open position and make sure you have your radio code before you ATTEMPT ANY OR THEAE PROCEEDURES ..or you could do yourself injury ..x