My sunroof won't close. I heard a loud noise before the problem started.
The loud noise might have come from the track. The sunroof is run by an electrical motor and slides on a track, much like a power window runs on a regulator. The tracks are made of hard plastic. The plastic can become brittle and break over time. This can bind the glass in certain positions. Sunroofs can be tricky to repair as there is limited space to work with, and sometimes the headliner needs to be removed in order to access certain parts. I suggest seeking help from a qualified mechanic to help repair your sunroof.