Prevent an error when resizing the window