Fix crash when maximizing a window.