Sonic Underground ends at episode 40.
The show was cancelled rather than given a proper finale, so the last episode wraps mid-arc. That's why the series has a bit of a reputation for an unsatisfying finish — the story was still building when production stopped.