Added synchronous log flushing to disk when a signal is received.