If you are creating loop device with partitions you should use losetup -P. Then the partitions will be removed with the device detach.
If you are creating loop device with partitions you should use losetup -P. Then the partitions will be removed with the device detach.