Fixed checking for closed channel