Handle wizard close correctly. Closes #4986.

Handle wizard close correctly.
Replace provider hardcoded path with helper.
Reorder some imports and remove unused ones.
Refactor connection and disconnection from backend.

[Closes #4986]