My old Alfa 155 had a habit of opening but then not closing the sunroof, if the day was very hot.
It would work when it was cooler out, so I had to leave the car in the shade for a while before it would decide that the time for an open roof was past.
Eventually it got more troublesome and I had to wind it closed with the emergency key.. and investigate fixing it.
My problem was the relay on the motor itself. It worked to "open" all the time... but not always to "close".
The only bad news if it's the relay, is that it's a special (Webasto in my case) relay that is like rocking horse poo and even the dealer couldn't order one as they were out of production). Second hand one from a Lancia Dedra worked for me.... so look for a Bravo with a sunroof at the breakers - it may be the same relay.
Ralf S.