NPE when closing XContentBuilder and using 'pretty' query parameter
fixes #4100