Jail descriptors broke the sys_jail_remove function in two, with prison_remove doing the second half of the work. To work with other callers, prison_remove requires the jail be held and releases the hold, so sys_jail_remove holds the jail before calling it.
But prison_remove only did half the job of removing the hold; it would keep it when bailing out from an attempt to kill an already-dying jail.
The fix is to remove the dying jail from prison_remove, and handle it in prison_deref instead (and to do it correctly).