let try_finalize f x finally y =
  let res = try f x with exn -> finally yraise exn in
  finally y;
  res;;