Issue #24: fix for early termination of main event loop