fixed looping issue eating up cpu
cleaned up shutdown to flush log queues.