Hello all, this is my first time posting. I have used this forum for much needed info over the years, but this is the first time I feel I have something to contribute. The rear glass "door" sensor is indeed built into, or functions in concert with the latching mech. On my 98 R50, I had to transport something that needed to stick out the window. In order to keep the door ajar light off, I snapped the latch closed while the rear glass was open. To release the latch, I placed into the clasp (where the loop on the glass would normally be held when glass closed) a screwdriver (tool, not drink lol) applied slight upward tension while turning key to open glass. It popped back open. So long story short, if the sensor is suspect, then you might have to dig that latch out.
Oh, and also I want to point out that in my case, I could get the light to turn off even with nothing in the latch by closing it, so it might not have anything to do with how far the window loop pushes in, but perhaps the position of the latch itself.