Use the exit statement to indicate successful or unsuccessful shell script termination. In this tutorial, you will learn how you can pass string data from bash function to the caller by using different types of bash syntaxes. But i want to put in a option to exit the script using the exit command. You can exit the xterm window by closing the window or type exit at the bash prompt. To exit from this running container, you can use ctrl+c, ctrl+d or enter exit in the terminal. To exit the function stack without exiting shell one can use the command: kill -INT $$ As pizza stated, this is like pressing Ctrl-C, which will stop the current script from running and drop you down to the command prompt. if [ $retVal -ne 0 ]; then echo "Error" fi exit $retVal @jww - well, that's not quite a good idea to go against convention Raise error in a Bash script. ./