Close channel correctly