Ensure error logs are flushed before quitting a process

This fixes #176