If your bash script is launching JMRI using one of the JMRI provided launchers, be aware that your bash script will wait until JMRI has exited before running the next command unless you explicitly put JMRI in the background.
You may need something like:
/path/to/JMRI/panelpro &
sleep 30
stty -F /dev/ttyS0 38400
Note the ampersand (&) after the call to JMRI.