Don't write to channel if closed. Fixes #18.
Merge pull request #19 from eaigner/master

Fixed #18