Call the implicit KisImageSP destructor with scoping.
Alternatively, we could remove the:
// check if the image has actually been deleted
KIS_SAFE_ASSERT_RECOVER_NOOP(!sanityCheckPointer.isValid());
check from KisDocument withhich seems a bit possessive about its current image.