Properly handle the provider setup defer canel.

Fix issues related to "Cancel login does not work".

[Closes #4869]
[Closes #4973]