Don't write to channel if closed. Fixes #18.