Fix: exceptions no longer stop the writer thread

The previous placement of the finally-clause caused the writer-thread to
end due to any exception. We don't want this to happen for exceptions
that we handle, such as a TCP/IP error.