Unable to switch between different browser instances for second time

I need to create a test case that includes two different browser instances and I have created 2 different browser instances.
I have opened the first browser instance and done some log in into the website and I have done similar steps in the other browser instance and now I need to switch to first browser instance and need to perform some actions and I was using this command

DriverFactory.changeWebDriver(driver1)

But it was throwing this error

Test Cases/2 browsers FAILED.
Reason:
org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
Driver info: driver.version: RemoteWebDriver
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:125)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:780)
	at com.kms.katalon.core.webui.driver.DriverFactory.setTimeout(DriverFactory.java:821)
	at com.kms.katalon.core.webui.driver.DriverFactory.changeWebDriverWithoutLog(DriverFactory.java:267)
	at com.kms.katalon.core.webui.driver.DriverFactory.changeWebDriver(DriverFactory.java:259)
	at com.kms.katalon.core.webui.driver.DriverFactory$changeWebDriver$0.call(Unknown Source)
	at 2 browsers.run(2 browsers:134)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1588052554411.run(TempTestCase1588052554411.groovy:25)

Can anyone help me how to overcome this issue and how to switch between differnt browser instances in the test case.
Thanks.

hi,
is this something what you are looking for

import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.remote.DesiredCapabilities
import com.kms.katalon.core.webui.driver.DriverFactory


//Use Katalon chromedriver
WebUI.openBrowser('')
WebUI.navigateToUrl('http://www.google.com')
WebUI.closeBrowser()

//use external chromedriver
ChromeOptions options = new ChromeOptions();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
System.setProperty("webdriver.chrome.driver", "C:/Users/xxxx/bin/chromedriver.exe");
ChromeDriver driver = new ChromeDriver(capabilities);
DriverFactory.changeWebDriver(driver)

//use Katalon chromedriver
WebUI.openBrowser('')
WebUI.navigateToUrl('http://www.google.com')

WebUI.closeBrowser()

Thanks, @Timo_Kuisma1 for your help but that is not my exact need.
I had a test case in which i have created 2 different browser instances using these commands and I have done some steps in those 2 browsers.
Now I need to go to the first browser again and I was using this command DriverFactory.changeWebDriver(driver1) , But I was getting error and I was unable to switch from the second browser instance to the first. I need to switch between browser instances to complete my test case.

WebDriver driver1 = new ChromeDriver()

DriverFactory.changeWebDriver(driver1)

WebDriver driver2 = new ChromeDriver()

DriverFactory.changeWebDriver(driver2)

Can anyone help me overcome this issue.
Thanks.

hi,

no issues when used like this way
System.setProperty(“webdriver.chrome.driver”, DriverFactory.getChromeDriverPath())
WebDriver driver1 = new ChromeDriver()
WebDriver driver2 = new ChromeDriver()

DriverFactory.changeWebDriver(driver1)
// first part of test

DriverFactory.changeWebDriver(driver2)
// second part of test

//back to first part of test
DriverFactory.changeWebDriver(driver1)

driver1.close()
driver2.close()