Fixed invalid access on iterator when invalidating windows