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