Correctly waiting for process to finish

Currently I have something like this:

ref = Process.monitor(worker)

receive do
  {:DOWN, ^ref, :process, ^worker, :normal} ->
    IO.puts("Normal exit from #{inspect(worker)}")

  {:DOWN, ^ref, :process, ^worker, msg} ->
    IO.puts("Received :DOWN from #{inspect(worker)}")

That worker have a start_link which send a stream of data into a consumer, all this happens inside a mix task, so if I dont add the receive do, as soon as the mix dies, it also kills the children process, same way as if I run it from a iex -S mix shell.

... some producer consumer in the middle
|> Flow.into_specs(consumer)

The thing is, when the flow is empty (is a finite flow), the worker doesnt seem to die, the receive do doesnt get triggered, is there any other way to achieve this?