Remove shapes where they are stored.

This fixes a segmentation violation when deleting unused shapes.