What happens to a Demon or Elemental when their service term comes to an end?

I can’t find anything in the third edition about what happens to a summoned demon or elemental when their service term is over. Looking for any reference to what happens? Do they immediately return to where they came from? Or are they free to do what they want?