Remove race condition when opening/closing substates in same update

This took a while to figure out the issue, seeing as it only happened one in sixty or so tries.

Basically, if you have a state with `persistentUpdate = true`, it's possible it might try to open a new substate when a substate is already open, which is fine. However, the substate may also have a way of being closed. If the substate tries to close on the same frame as the parent state tries to open a new substate, there is a race condition which can result in the new substate not opening.