This method is used to detach the browser instance from a window
that it was previously attached to using either the Attach
method. It is automatically called by the class destructor when the browser
is no longer needed and the host window is being destroyed. If the
browser was created using the Create method, calling
this method has the same effect as calling the Close method.
This method will cause the WEBVIEW_EVENT_WINDOW_DETACHED
event to fire as part of the normal process of detaching from the window.
If you implement a handler for this event, you should never delay this
process by attempting to show a dialog or request input from the user
(for example, by displaying a message box). At the point this event is
fired, the browser objects have already been disposed and there is no
way to prevent the process from completing.
If there is a navigation in progress at the time this method is
called, it will be canceled. If there are one or more file downloads
in progress, the transfers will be aborted.
The current thread will block while it waits for the WebView2
browser process to shutdown gracefully. If the browser becomes
non-responsive, this method will wait several seconds before
forcibly terminating the child process and continuing with the cleanup
process. If a temporary user profile was specified or a private
browsing session was created, this method will also clear the
browser cache and remove the user data folder that was created for the
session.