there is no real way to stop a user from closing a window using a shell script.
but if your worring about your shell script being half way through something when they close the window.
use
nohup
this makes the process not honour hang up signals
NOTE: you will no long output stuff to the tty, so if you want user imput its prolly best to do as follows, run a process asking for the imput without nohup then run another process accepting the input from the command line with nohup.
I havent checked this but you may also be able to run a function as nohup, I don't know.