Do something after Task death

IIRC tasks are linked to the calling process

When invoked, a new process will be created, linked and monitored by the caller. Once the task action finishes, a message will be sent to the caller with the result.

The calling process will need to trap exits, handle the task’s abnormal termination, and then perform the cleanup. This is described here, but what that really means is you just need a handle_info to capture the exit message.