bugfix: call on close, flush before clsing
allow multiple daemon instances, flush before close
ludent