Better handling of closing windows, though not by much