Shells can be nested: a graphical terminal starts a shell, an SSH connection starts a remote shell, and a shell can start another shell. Leaving one normally returns control to whatever started that current shell.
Command Line · Lesson 19
exit
Learn how to leave the current shell and choose the status it returns to its caller.