[1.7.x] Improved GIS migration test cleanup; refs #23504.

Backport of 8facb02faf from master