     (elfeed-curl--prepare-response url n)
     (if (not (and (>= elfeed-curl-status-code 400)
                   (<= elfeed-curl-status-code 599)))
-        (funcall cb t)
+        (unwind-protect
+            (funcall cb t)
+          (when (zerop (cl-decf elfeed-curl--refcount))
+            (kill-buffer)))
       (setf elfeed-curl-error-message
             (format "HTTP %d" elfeed-curl-status-code))
-      (funcall cb nil))))
+      (unwind-protect
+          (funcall cb nil)
+        (when (zerop (cl-decf elfeed-curl--refcount))
+          (kill-buffer))))))
 
 (defun elfeed-curl--fail-callback (buffer cb)
   "Inform the callback the request failed."
   (with-current-buffer buffer
-    (funcall cb nil)))
+    (unwind-protect
+        (funcall cb nil)
+      (when (zerop (cl-decf elfeed-curl--refcount))
+        (kill-buffer)))))
 
 (defun elfeed-curl--sentinel (process status)
   "Manage the end of a curl process' life."

            (progn
              (when (functionp cb)
                (setf cb (make-list (length url) cb)))
              (setf elfeed-curl--requests (cl-mapcar #'cons url cb)))
          (push (cons url cb) elfeed-curl--requests))
        (setf (process-sentinel process) #'elfeed-curl--sentinel)))))

(defun elfeed-curl--request-key (url headers)

          (setf elfeed-curl-error-message status))
        (cl-loop with handler = #'elfeed-curl--fail-callback
                 for (_ . cb) in elfeed-curl--requests
                 do (run-at-time 0 nil handler buffer cb))))))

(defun elfeed-curl-retrieve (url cb &optional headers)
  "Retrieve URL contents asynchronously, calling CB with one status argument.
