hmmmmm, when its closed hit the tilt button then try to close again, hold the button. see if that doesnt work. now chances are this might have not worked, but its the first check id do. next thing to do is open it up and see if anything is loose. like you stated nuts bolts. etc.
and lastly , id take it to a pro to get it checked. reason is that when it comes to the sunroof, its best not to mess. get the pros to do it.
p.s- welcome to the forums