My old Magit setup left a bunch of buffers around that I didn’t need anymore. Here is the posted solution to close them automatically:
(defun help/magit-kill-buffers () "Restore window configuration and kill all Magit buffers. Attribution: URL `https://manuel-uberti.github.io/emacs/2018/02/17/magit-bury-buffer/'" (interactive) (let ((buffers (magit-mode-get-buffers))) (magit-restore-window-configuration) (mapc #'kill-buffer buffers))) (bind-key "q" #'help/magit-kill-buffers magit-status-mode-map)