add quit channel and lock.