I would recommend implementing some goto placeholders in your batch file so that your script can follow a well defined path or workflow.
Similar to the answer here... Batch - If, ElseIf, Else
If you need to run a command initiated from the batch file you can use the /C flag to close the new window once the command is completed.
See this answer here... BAT file: Open new cmd window and enter code in there
Also...Here's an example that I had lying around which allows for user input if you require multiple tasks within the batch script. Included are two examples with the /k flag that allows the windows to remain open, and the /C flag that closes the initial command prompt.
@echo off :start cls @echo Select An Action: @echo. @echo 1= Task 1 (new cmd /C, start npm -l) @echo 2= Task 2 (new cmd /k, start npm -l) @echo. set /p userinp=Enter Your Choice: set userinp=%userinp:~0,1% if "%userinp%"=="1" goto 1 if "%userinp%"=="2" goto 2 if "%userinp%"=="3" goto 3 if "%userinp%"=="4" goto 4 if not "%userinp%" =="" @echo Invalid Choice pause goto start :1 start cmd /C start npm -l @echo Task 2 Complete... @echo. @echo Closing in 10 seconds... timeout /t 10 goto end :2 start cmd /k start npm -l @echo Task 2 Complete... @echo. @echo Closing in 10 seconds... timeout /t 10 goto end :end exit