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 which seems a bit possessive about its current image.