Improve broken pipe handling of CLI

If the output of the NIPAP cli is being piped and the receiver of the
pipe is killed off before nipap (for example, using ^C) there won't be a
pipe anymore and Python will print an ugly "broken pipe" backtrace that
could look a bit different depending on which version of Python we are
running on but in general it confuses users. To avoid this, we register
an atexit handler which will try to close stdout before we exit and thus
suppress the message.

Fixes #464.
Merge branch '464-broken-pipe'