This test is more accurate
(when (eq t (window-deletable-p win))
instead of simply
(when (window-deletable ...
window-deletable-p may also return 'frame. At least on my setup, trying to delete such a window throws an error.
Ex, I get 'frame, when there is only one window.
Oh, that makes sense -- thanks, merged.