Stop an Event Trace session
        Stop an Event Trace session that you have started earlier with the
    .PARAMETER SessionName
        Name of the tracing session that you want to stop
        Default value is ""
        PS C:\> Stop-D365EventTrace
        This will stop an Event Trace session.
        It will use the "" as the SessionName parameter.
        Tags: ETL, EventTracing, EventTrace
        Author: Mötz Jensen (@Splaxi)
        This cmdlet/function was inspired by the work of Michael Stashwick (@D365Stuff)
        He blog is located here:
        and the blogpost that pointed us in the right direction is located here:

function Stop-D365EventTrace {
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
    param (
        [string] $SessionName = ""

    end {
        Write-PSFMessage -Level Verbose -Message "Stopping the trace" -Target $SessionName
        Stop-Trace -SessionName $SessionName -ETS