Anomaly cancellation in the topological string