How to close the Terminal app using the terminal command-line("exit") in macOS Catalina
In Terminal &gt; Preferences… &gt; Profiles &gt; Shell, the default setting for When the shell exits: is: Don't close the window
This can be changed to: Close the window
Then the exit command will close the window.


Edit to address the edited Question:
If you want to close the window using the exit command you can do as suggested in the first part of this answer, however, if you also want to automatically and gracefully close Terminal as well, as part of your script or in place of the exit command as shown in your question, then you can do the following:
First create a simple AppleScript application using the following example AppleScript code in Script Editor:
tell application &quot;Terminal&quot; to if (busy of windows) does not contain true then quit

Saving it as an application named e.g. QuitTerminal in the main Applications folder.
After saving it, open Terminal and then open e.g. QuitTerminal in order to trigger allowing permissions under System Preferences &gt; Security &amp; Privacy &gt; Privacy
Once this is done you can then use the following at the end of your script or in place of the exit command:
open -a &quot;OuitTerminal&quot;

Example based on command shown in your question:
/Users/harikrishna/Desktop/youtube.sh ; open -a &quot;OuitTerminal&quot;

This will only close Terminal if there are no running processes in any of the windows in Terminal.
Note: If you do not want to see e.g. OuitTerminal show in the Dock, you can modify the application using the following command in Terminal:
defaults write '/Applications/OuitTerminal.app/Contents/Info.plist' LSUIElement -bool yes


If you do not care about any running process you can force close Terminal from the script or command using killall Terminal in place of exit; however this is messy and I do not recommend using it over what's presented  above.