Ensure all events are flushed in case of earlier termination, closes #3