Emacs: kill all buffers

Christian Kruse,

I don't really know where I got this from (I'm sure that I didn't write this myself), but this is one of my most used macros when switching projects:

(defun kill-all-buffers ()
  (interactive)
  (mapcar 'kill-buffer (buffer-list))
  (delete-other-windows))

(global-set-key (kbd "C-x K") 'kill-all-buffers)

This fun kills all buffers you opened in an emacs instance and binds it to C-x K.