Every time I close the laptop lid, press the power button, shut down the computer or restart it, it's freezing (SysReq+REISUB doesn't help either).

When I'm on a terminal only TTY and close the lid I get following kernel messages:

wlp20f0: deauthenticating from XX:XX:XX:XX:XX:XX by local choice (Reason: 3=DEAUTH_LEAVING pcieport 0000:00:1c.0: BAR 14: no space for [mem size 0x00200000] pcieport 0000:00:1c.0: BAR 14: failed to assign [mem size 0x00200000 64bit pref]

followed by many other lines basically repeating the last two messages just with other addresses. wlp20f0 is my WiFi device which works just fine. This WiFi related message only comes when closing the lid.

This happens on Linux 4.10 as well as on 4.11. The problem is present since I have Ubuntu 17.04 installed. The Laptop is a HP 250-G3.

The last message I get when trying to shut the laptop down is: