In delete_frame record selected frame only after calling Qdelete_frame_functions...