I'm looking for a way to automatically do some clean up tasks when the PowerShell session quits. So for example in my profile file I start a process which needs to run in the background for quite a lot of tasks and I would like to automatically close that process when I close the console.
Is there some function the PowerShell automatically calls when closing the session as it does with prompt
when displaying the prompt?