Fix an assertion failure seen on the layout tests, and when closing the window after...