writeback: avoid use-after-free after removing device