Hi,
You can create (just hit Ctl+k) and name variable x in the application window property for each attach window.
and use it in close window activity(you just need to pass the variable x in the UseWindow property)
Please go through the UiPath Academy for more.
https://academy.uipath.com/lms/index.php?r=site/index
Happy Automation.