BS-8554: add a conditional wait to wait that the popup properly close