Interesting project. How does the caffeinate spot keep the Mac awake with the lid closed? As far as I know, caffeinate on its own doesn’t stop sleep when the lid is closed without an external display. Do you use pmset disablesleep, and how do you get normal sleep back if the app crashes?