Maybe I misunderstand your scenario, but it reads like you are using microflow A to open popup A in which you have a redirect widget to open popup B and are looking for a way to close popup A?
you already tried the close page action in microflow A, right?
I have found solution
Steps
1- Added a close page button with random class myButton, no need to add in CSS style file
2- use below code
setTimeout(
() => {
document.getElementByClassName(‘cmyButton")[0].click();;
}, 5000 );
as getting list so [0] will give the first from my clicked list and will close the pop up after 5 seconds