Simplify compareAndSet usage
Remove unused variable
Avoid NPE during close
Get the channel once in drainQueue
Tolerate null channel when writing

Channel can only be null during a write if we are disconnecting as, in
order to be able to write, the writer must have received a non-null
Channel reference.