Fix segmentation faults due to KeyPress handling continuing post-delete