Replace the current state with a new one.
Safely exits and removes the old top, then pushes the provided state and enters it.