To fire a plugin when an incident is resolved we need to register the plugin in
Close message for the incident entity.
And in the input parameters of the context we need to check for IncidentResolution.
This entity is a special entity that holds the information about the incident record that is being closed.
The sample plugin below gets the actual end attribute value of IncidentResolution and subtracts created on attribute value of Incident to get the duration and updates the duration (custom field) in the case being resolved.
The helpful post