use safe chan closing