<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ensure_stopped(self):
 """Idempotent channel stop"""

        if not self.active:
            return self
        self.stop()
        self.observer.cancel()
        self._manager.remove_routes(self, self.get_routing_keys())
        self._active = False
        return self