let with_dispose ~dispose f x =
  finally (fun () -> dispose x) f x