runtime: more robust implementation of caml_final_do_all_calls