Shut down the profiler in headless compositing mode

This fixes a hang in content tests in my deleafset branch. No idea why it worked before though…

This just replicates the code in non-headless mode over to the headless mode.

r? @kmcallister