Hey @amacg, I did a bit more testing after you posted, and yeah you’re right in that ofExit() does not immediately terminate the application. So it works, but not immediately. And if you need an immediate exit then it doesn’t really work well for control, if that makes sense.
If I call ofExit() in ofApp::setup(), the app never launches a window, but ofApp::update() and ofApp::draw() run about 60 times or so. If I call ofExit() in ofApp::update(), the remaining code in ofApp::update() finishes , and ofApp::draw() runs one final time too, but then that’s it.
I could be wrong, but I think oF has to have a chance to check and unwind some stuff (memory, listeners, close the window, etc) before it exits. I like the way you solved it though with the if-else approach. Sometimes an empty directory or an unallocated ofImage can cause problems like you said. So checks and controls are a great way to avoid crashes and undefined behavior.