Close connection if peer closed.
Print a proper stacktrace if an error occured and close connection.