This fixes the issue by trapping exits for the duration of the fun,
then turning exit trapping off and killing the process if there is an
exit message in the mailbox.
The real-world case where this fixes things is Pleroma MediaProxy.
Without exit trapping, the process would get killed if the connection
was closed client-side and a counter would be left incremented.
I am not sure if trapping exits is the optimal solution, but I don't
see any other option.