wiat for thread to finish after cancel
this avoids error on return when closing the viewer window