It sounds weird, but I configured my Ubuntu 18.04-4 LTS to shutdown immediately when I press the power button but it works fine ONLY when the HDMI monitor is connected.
If I disconnect the monitor (I usually use this PC without a monitor), the power button doesn't work anymore. As soon as I connect again the monitor, the system automatically shuts off.
It seems like he looks for the monitor before to power off.
Why this happen and how can I solve it? I need to power off the computer when I press the power button and I can't connect the monitor since I use this computer by remotely connecting to it.