FIXIED: the thread to properly update keys

Fixed the thread so it properly exchanges keys and actually cancels the loading dialog.