its me again with funny issues

I have the main stack where I put the connection/disconnection on openStack/closeStack.
Code: Select all
on openStack
connectDB
end openStack
Code: Select all
on closeStack
closeDatabaseConnection
end closeStack
So is there any function like on closeMainStack or to have:
if "only the particular name of the stack" is closed then closeconnection else do not close connection end if
The code that I need, must be on main stack script
In other words how can I close connection when the main stack is closed not substack