Remove related shapes first, to make sure that everything is cleanly deleted.