Hi!
Yeah, its not that simple sadly, the "collapse" flag is responsible for the collapse state of the UI, if you want it to keep the same state after reopening, you'll need to feed it the value from another source.
Now it depends on what behaviour you want. If you want the UI to open in the same state in all Scenes on the same machine, you normally store the state of the collapse flags of your UI in an optionVar in the preferences.
If you want your UI to have Scene specific collapse states and open the same in the scene you are working in, but in a different state you saved in another scene you are working in, you would normally store the collapse settings on a hidden node (most commonly a network node) as an attibute and then gather it again from there.
You could also store the collapse state in a global variable, that way the UI will open up the same during the current session, but revert to default once maya is closed an opened again. But global variables can become quite problematic, and while they are fine for something simple like this, I wouldn't make a habit out of using them.
If you want some more information on one of these methods, let me know.
I hope it helps!