refactory shutdown hook/block device