Spooky control flow with Format.kasprintf & friends

Well, I’d honestly never considered doing all of my “extra” work inside the continuation provided to e.g. kfprintf. Putting a pin in that for the moment though, how in the world is the flush in this snippet happening before formatting?

let k = Format.(kfprintf (fun _ -> k ()) str_formatter fmt) in
let msg = Format.flush_str_formatter () in ...