Selecting the about to be deleted frame in a delete-frame-function aborts Emacs, because this change goes undetected by the function delete_frame. The following lisp code should produce this behaviour. (add-hook 'delete-frame-functions 'select-frame) (let ((f1 (make-frame)) (f2 (make-frame))) (select-frame f2) (delete-frame f1) (delete-frame f2)) At the very top, delete_frame reads the selected frame into the variable sf, then... struct frame *f = decode_any_frame (frame); struct frame *sf = SELECTED_FRAME (); ... safe_call2 (Qrun_hook_with_args, Qdelete_frame_functions, frame) // does effectively SELECTED_FRAME = f and thus ... /* Don't let the frame remain selected. */ if (f == sf) // is false, but sf does not actually hold the // SELECTED_FRAME anymore. So, the dead frame f remains selected and this leads to an emacs_abort, the next time SELECTED_FRAME is invoked. Solution: Read SELECTED_FRAME into sf before it's first use, but after calling the hook.