Automatic call disconnect

Is there any ways to leave a room without pressing the cut button, rather through code?