NEX-1938 Backport NEX-1923 Retiring a device may hang or leave device unusable after unretire (add sunwhea)