The two operations affect each other, probably because window is a global variable. Please add window = null;
before the var thread = new Thread...
in Activate
. I tested with this added and it works well.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.