<PackageReference Include="Microsoft.Win32.SystemEvents" Version="10.0.0-preview.5.25277.114" />

SessionEndingEventArgs

Provides data for the SessionEnding event.
public bool Cancel { get; set; }

Gets or sets a value indicating whether to cancel the user request to end the session.

public SessionEndReasons Reason { get; }

Gets the reason the session is ending.

Initializes a new instance of the SessionEndingEventArgs class using the specified value indicating the type of session close event that is occurring.