The switch is in the boot/trunk lid, beside the latch. Pull back the carpet to get at it. You can see a post in the boot/trunk opening that actuates it. My E34 did the same thing as yours. I opened the switch and found it had corroded and a copper leaf spring had broken. I soldered it, cleaned out the corrosion, and stuffed the switch with grease to prevent corrosion. No problems since...