Ensure that dialogs are always correctly deleted when appropriate. Also, if an algorithm is running in a background task and hits an error, we automatically re-show the algorithm dialog and the associated log for debugging. Fixes #16858