Catch and log exceptions that happen in finish_request

This PR catches and logs exceptions that happen in `finish_request`. This prevents the exception from falling back to the PSGI servers, most of which have horrible support for properly logging errors.