ArcGIS Pro 2.7 API Reference Guide
CloseTaskAsync Method
Example 

ArcGIS.Desktop.TaskAssistant Namespace > TaskAssistantModule Class : CloseTaskAsync Method
A unique identifier used to identify the task item to be closed. This identifier is the return value from the OpenTaskAsync(String) or OpenTaskAsync(String,Guid) API calls. Alternatively the identifier can be retrieved from the Task project item with the TaskProjectItem.TaskItemGuid property.
Closes and unloads a specified task item from the Tasks pane. Also removes the task item from the project.
Syntax
public static Task CloseTaskAsync( 
   Guid taskItemGuid
)
Public Shared Function CloseTaskAsync( _
   ByVal taskItemGuid As Guid _
) As Task

Parameters

taskItemGuid
A unique identifier used to identify the task item to be closed. This identifier is the return value from the OpenTaskAsync(String) or OpenTaskAsync(String,Guid) API calls. Alternatively the identifier can be retrieved from the Task project item with the TaskProjectItem.TaskItemGuid property.

Return Value

A Task that represents CloseTask.
Exceptions
ExceptionDescription
This must be called on the UI thread.
Example
// find the first project task item which is open
var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault(t => t.IsOpen == true);
// if there isn't a project task item, return
if (taskItem == null)
  return;

// close it
// NOTE : The task item will also be removed from the project
TaskAssistantModule.CloseTaskAsync(taskItem.TaskItemGuid);
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

TaskAssistantModule Class
TaskAssistantModule Members