Clicking cancel on a history export does not prove the worker has stopped. A private online text inbox may still be reading records, writing a temporary file or preparing delivery. Define cancellation requested, cancellation completed and ordinary completion so the user can understand what actually happened.
Identify the exact job being cancelled
Use the stable job reference, intended resource, requested range and authorised requester. A recent timestamp or shared filename is not enough to choose the object. The cancellation route needs its own permission check rather than accepting an external identifier as authority.
Queued work and running work can have different supported behaviour. The status view should say whether cancellation is pending or has reached the defined stop point. Do not label both complete before the worker’s actual outcome is known.
Retain enough job state for that decision. Removing a row from the visible list can hide the task while leaving its process and storage responsibilities active elsewhere.

Make the worker observe the decision
If the design supports cooperative cancellation, check the controlled job state at suitable boundaries and stop subsequent work accordingly. The cancellation request and running process need a defined way to coordinate.
Normal completion can race with cancellation. Choose an explainable final state and inspect whether a file exists, whether it may be delivered and what happens to outputs already obtained. Cancellation should not be described as recalling a file already downloaded by a user.
Define what to do when the cancellation response is lost. The client should be able to query the same job rather than create another export to discover whether the first one ended. Repeated supported cancellation requests should not affect unrelated work.
Assign temporary-output cleanup separately
Incomplete files, storage objects and task logs need an explicit handling responsibility. Avoid deleting material another task still uses. Cancelling an export is also different from deleting the underlying SMS history.
After a process failure, identify unfinished jobs through the supported recovery procedure. A missing process does not by itself prove either success or cancellation. Preserve a clear unresolved state until the relevant facts are established.
Define what the user sees when cancellation arrives after normal completion. An accurate already-completed result is better than silently deleting the file or pretending the process was interrupted. Any separate request to remove a finished output needs its own scope and authorisation. Keep these operations distinct in the interface, worker state and audit record.

Test race and restart conditions
Use fictional data for cancellation while queued, cancellation during processing, a request near completion and a lost response. Requery the job and inspect its final state and file outcome through the actual route.
Include worker restart and a relevant permission change. A restored worker should not silently resume from an older uncancelled decision. The test needs the application’s real state transitions, not only a disabled browser button.
Record the job reference, requested transition and confirmed output handling without retaining private message exports as fixtures. Close when the stop and delivery boundaries are understandable, including any limits on already produced material. That provides a useful contract for the user and operator, rather than making a local click appear to control every asynchronous component immediately.
