When in your original test case '(pop-to-buffer "*Occur*")' is replaced
with '(kill-current-buffer)':
(define-key isearch-mode-map (kbd "M-s o")
#'(lambda ()
(interactive)
(call-interactively 'isearch-occur)
(kill-current-buffer)))
then it fails with:
Error in post-command-hook (isearch-post-command-hook): (error "Selecting deleted
buffer")
All other uses of 'isearch--current-buffer' have a check for a live
buffer, e.g.
(unless (eq (current-buffer) isearch--current-buffer)
(when (buffer-live-p isearch--current-buffer)
(with-current-buffer isearch--current-buffer