You need to look at the alert log before you issue the second shutdown command. My guess is that the database is not shutting down completely which is leaving some processes behind. Also make sure that all of you scripts have exactly the same environment scripts. If your database starts with ORACLE_SID=MYSID but your scripts have ORACLE_SID=mysid, your script will look like it is shutting down the database, but it won't. the sid name is case sensitive in Unix/Linux.
this space intentionally left blank