pipe: Prevent error when logging line with unicode
log: Avoid globals
log: Log shutdown errors
pipe: Close pipes on shutdown