Finally figured this one out, wasn't the code.
I was missing a pull-down resister on pin 17 for the push button input (shutdown button).
Odd that with HDMI plugged in it worked; un-plugged it didn't. The input must float around the threshold so the HDMI load pulled it down low enough.