iCloud Syncing - Log in, log out issues

Using the final CloudNotes project, I am trying to handle login, logout issues. It appears that everything works ok with some finagling (closing Settings, returning to CloudNotes, reopening Settings, etc.). However, if I do not switch back to CloudNotes and restart Settings, Settings seems to get hung up on “Saving.” This seems like a bug to me.

What is going on? Am I supposed to use multithreading for this?

Thanks!