sunroof motor works on a certain # of revolutions before it stops. If this is off track, be VERY careful when tilting your roof... it'll continue trying to push up when the roof is already up and you'll break your sunroof lifters.. (they're plastic)... around $60 for the parts, and a lot of pain and hassle to fix em.
for your problem:
open your sunroof motor liner.
close the sunroof.
pull the motor out, while keeping it plugged in.
push the button on your sunroof until it's in the position where if you push it a 2nd time it'll go into "lift" mode.
Put it back in place, bolt it up... and you're good to go.