Senthil, Unfortunately the sqlplus session was still running in the background when I tried the 'print -f exit' inside the trap. However, that got me rethinking the problem. What worked was the the following: trap 'kill %2;kill %1;exit' 1 2 3 15 I realized that I had two background jobs running, the sqlplus session and the first while loop containing the SQL. So the trick was to kill the first while loop (%2), then the sqlplus (%1) and finally exit the second while loop. No errors now when I Ctl-C and no background processes left running. Thanks for your feedback, it did help. David On 5/18/07, Senthil Subramanian <skumar.sen@xxxxxxxxx> wrote: You could try 'print -p exit; exit;' in the trap command to exit gracefully from both SQL*Plus and the shell.