Handle identity state transitions cleanly.