Add local channel termination

Also removed unused vars, housekeeping of stateful resources.