Ensure that the errorWrapper is closed when a new document is opened (issue 4625)