qemu-img: avoid calling exit(1) to release resources properly