finally i found this somewhere
public static void closeSafariTabs (WebDriver webDriver) {
try {
Set contextNames = ((AppiumDriver) webDriver).getContextHandles();
for (String contextName : contextNames) {
if (contextName.contains("WEBVIEW"))
((AppiumDriver) webDriver).context(contextName);
webDriver.close();
}
} catch (Exception e) {
}
}