Waiting for open windows to close

Kevin,
Welcome to the forum. :wave:t4:

As you can see in your post your code is messed up because you did not format it as code. So when you post code or sample data or console output please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance

Wait-Process will wait until a process stops. It will not stop them. So you simply combine both cmdlets

$ProcessList = 
    Get-Process |
        Where-Object { $_.mainwindowtitle -and $_.processname -ne 'powershell' }
$ProcessList | Stop-Process
$ProcessList | Wait-Process