let unload t = match t.database_handle with | Some s -> Measurements.flush t >>= fun () -> Database.close s | None -> return ()