Shutdown prompt keeps popping up I have a weird problem. Recently, I have noticed whenever I connect my MacBook Pro to my screen, the shutdown prompt (see picture) pops up and no matter how many times I click on "Cancel" it keeps popping up. It even steals the screen attention (that window gets highlighted) meaning that I'm not able to do anything at all.
Usually, it stops after a while (like 10 minutes or more), but it is nondeterministic.

I have a theory about what can be the cause. The screen I have is one of these old Apple Cinema displays (maybe ten years old), and it has a power button (touch-based) on it. I think it must be related to this. Somehow it feels as if the button is continuously getting pressed. In the Display preferences, there is an option related to the button. It's already set to "Does nothing" but the problem still occurs. I tried changing it to "Turns the display on and off", and the display started blinking, constantly turning on and off, which proves my hypothesis is correct. However, I have no idea what this is happening and how I can stop it.

Any ideas?
It might your keyboard issue which is just a random guess. However before going on hardware, why not you try to reset SMC. 

The System Management Controller — or SMC — is responsible for various pieces of hardware inside your machines such as the battery, fans, logic board and more. 


The SMC is even responsible for recognizing when certain buttons are
pressed.


You can take the guidance from https://support.apple.com/en-us/HT201295

It doesn't hamper anything so I think it is worth to try.