     {:ok, handler_pid} = ServerSpy.start_link
 
     on_exit fn ->
-      [handler_pid, client, server]
-      |> Enum.each(fn pid ->
-        ref = Process.monitor(pid)
-        Process.exit(pid, :normal)
-        receive do
-          {:DOWN, ^ref, _, _, _} ->
-            :ok
-        end
-      end)
+      wait_for_exit(handler_pid)
+      wait_for_exit(client)
+      wait_for_exit(server)
     end
 
     {:ok, port: port, client: client, server: server}

    refute Process.alive?(ctx.client)
  end

  thrift_test "clients don't retry by default", ctx do
    Process.flag(:trap_exit, true)

    new_server_port = random_port()

        :ok
    end
    Process.flag(:trap_exit, true)
    Process.exit(ctx.server, :kill)

    client = ctx.client
