I have a question regarding the best practice for closing Microsoft Edge instances in UiPath.
In my process, there may be multiple Edge windows open. I would like to ensure that all Edge instances are closed before starting the automation.
Is using the Kill Process activity with the process name “msedge” sufficient to terminate all Edge instances?
Or is it recommended to first retrieve all running Edge processes (e.g., using Process.GetProcessesByName("msedge")) and then loop through them to kill each instance individually?
From a reliability and best practices perspective, which approach do you recommend, and are there any advantages to one over the other?
A Kill Process activity will be sufficient to kill all instances of MS Edge. One activity will sort it out.
In terms of best practice, you should aim to close all those Edge instances in your previous automation process once it ends. It should logout and close all instances gracefully so that you’re not losing anything important within those tabs. You can also achieve this by using the “Close” property within you Application Browser scope. That is a safe and graceful close - rather than ending/killing the process via task manager.
So try getting all your processes to end by closing all Edge processes, and then for safety as a “double check”, you can use a Kill Process activity in your Initialization of each processes to confirm that all previous instances are closed.
You definitely don’t need to loop through it - it would serve no purpose as opposed to killing it once for all instances, unless you specifically want to see how many of that instance is running.
You can use Kill Process activity to close entire edge, that will better option to close the edge and it will take less time to close comparing to for each.
You can think like using Kill process activity as closing the browser from task manager.
using loop manually clicking on close button on each tab.
Follow the REFramework standards by closing the instances instead of killing. If fail to close, then only Kill the browser using Kill Process activity.
Why to avoid Kill process- Abruptly ending the process can corrupt local storage, browser cache, or the UiPath Browser Extension itself, rendering the bot unable to interact with web pages in subsequent runs.
Gracefully close the instances first - use Close Application with a short timeout, letting Edge shut down normally.
Fall back to Kill Process (force) only if it doesn’t close in time - handles stuck/unresponsive instances.
Disable session restore popup in Edge (Settings > Start, home, and new tabs, or via policy/registry) - biggest reliability win, since it prevents the “Continue where you left off” prompt even after a forced kill.
Instead of using Kill Process initially, try closing the Edge browser (or any browser) using the appropriate browser close activity.
Use Kill Process only as a fallback if the browser fails to close normally. This approach is especially beneficial when the process is running on a VM, as it helps close only the specific browser instance or tab being used by the automation, rather than terminating all open browser sessions.
You can use the Kill Process activity and set the AppliesTo property to OnlyCurrentUser. This ensures that only the processes started by the current user are terminated, which is especially helpful when deploying bots to Production environments where multiple users or robots may be running on the same machine.