Flush logs before quitting worker process