What is the context where you call it? I tried Artems solution and it worked (encapsulating it in another list).
Maybe try it with an array or an iterator instead.
Array
Collection<Window> windows = UI.getCurrent().getWindows();
Object[] array = windows.toArray();
for (int i = 0; i < array.length; i++) {
((Window)array[i]
).close();
}
Iterator
Iterator<Window> windowList = new ArrayList<>(UI.getCurrent().getWindows()).iterator();
while (windowList.hasNext()) {
Window next = windowList.next();
next.close();
}