Using the method externally is fine. But observe that 1) the actual value is internal and no assumptions should be made about it; and 2) the method has been exposed primarily to support the @PreserveOnRefresh feature. For keeping the state of components between refreshes, we recommend using that feature rather than accessing ExtendedClientDetails::getWindowName directly.
Yes, the data can be stored in any of the components in the preserved view. There is no built-in feature in the framework to have data cleared once a tab is closed ([open ticket]
(https://github.com/vaadin/flow/issues/8399)). In fact, all preserved components are stored in the session and will be disposed only when the session expires. A solution may be to use the onbeforeunload event together with a @ClientCallable server method (see e.g. https://vaadin.com/forum/thread/17845554/executejs-with-onbeforeunload-or-similar-events) to dispose the data one when the browser is closed. Since the event also triggers on refreshes, the disposal action would need to be delayed until the server has verified that the same view is no long refreshed.