updated to support smooth termination with daemon lock removal as well