Push all the overlays in an array when created (as usual). Following code will clear both map and the array:
pop() method of an array removes the last element of an array, and returns that element. 'while' keeps that happening as long as there are elements in the array. When overlays does not exist anymore, the mission is completed and code will proceed.
Applied in the example of the previous post.