       end)
     end)
 
-    # Assert the process is down then invoke capture_io
-    # to trigger the ExUnit.Server, ensuring the DOWN
-    # message from capture_log has been processed
     assert_receive {:DOWN, ^ref, _, _, :shutdown}
-    ExUnit.CaptureIO.capture_io(fn -> "oops" end)
-
-    assert GenEvent.which_handlers(Logger) == handlers
+    wait_capture_removal()
   end
 
   test "log tracking" do

        refute logged =~ "[warn]  two\n"
    end
  end
end

    end) == ""
  end

  @tag timeout: 2_000
  test "capture removal on exit" do
    {_pid, ref} = spawn_monitor(fn ->
      capture_log(fn ->
        spawn_link(Kernel, :exit, [:shutdown])
