I'm posting this to see if it is a known issue with the XPS13, as if not it may be an Ubuntu (17.04) bug:
If I install a Kernel update via apt: `sudo apt-get update && sudo apt-get upgrade` and then reboot, my system will not hibernate when the lid is closed - with or without mains power plugged in.
After some time (usually a few hours) Unity's Software Updater tells me my system needs to be rebooted and after I do the problem disappears. This has now happened at least 3 times with previous Kernel updates (currently 4.10.0-26).
I suspect Software Updater is the cause, but I'd like to hear from other XPS13 users - in case it is specific to the hardware/firmware.
Note that hibernate and sleep are very different things. Which one are you talking about? Also, you mention it doesn't work well when you close the lid. What if you do it manually from the menu in the upper-right corner?