tomcat automaticaly stop in menu script

i have a problem with the code I created (see below).

a. when I logged in as root and su to tomcat, i can execute all options. when I press X, it will exit properly.
b. when I logged in directly as user1, I can execute also all options. if I press X i will logout automatically to putty. However I noticed that if I exit, tomcat process also stop when I run ps -ef | grep tomcat

I do not know why is that happening if I logged in directly and exit

user1 :/home/user1:/home/user1/script.sh

#!/bin/sh

TOMCATDIR=/home/tomcat/apache-tomcat/bin/

menu() {
    done0=n
    while [ "$done0" != "y" ]; do
    clear
        cat <<EOF
          
                        [1] Stop app1
                        [2] Start app2
                        [3] View tomcat process

                        [X] Exit
            

EOF
    printf "           Enter your option =>> "
    read choice
    case "$choice" in
        1) startapp;;
        2) stopapp;;
        3) viewapp;;
        x|X) done0=y;;
    esac
    done
    clear
}

stopmrs() {
        echo "Stopping Tomcat "
        sudo su - tomcat $TOMCATDIR/shutdown.sh
        echo "Press enter to continue."
        read enterkey
}

startmrs() {
         echo "Starting Tomcat"
         sudo  su - tomcat $TOMCATDIR/startup.sh
         echo "Press enter to continue."
         read enterKey
}

menu

I doubt the options would work since you call
startapp
stopapp
viewapp

whereas your function names are
stopmrs
startmrs
... and "viewrms" doesn't exist.

(or we don't have all the infos)

sorry just a typo error. when I logout the tomcat also stop..logout Im out also on putty/