def stop(self):
        # type: () -> bool
        """
        Stops the framework

        :return: True if the framework stopped, False it wasn't running
        """
        with self._lock:
            if self._state != Bundle.ACTIVE:
                # Invalid state
                return False

            # Hide all services (they will be deleted by bundle.stop())
            for bundle in self.__bundles.values():
                self._registry.hide_bundle_services(bundle)

            # Stopping...
            self._state = Bundle.STOPPING
            self._dispatcher.fire_bundle_event(
                BundleEvent(BundleEvent.STOPPING, self)
            )

            # Notify listeners that the bundle is stopping
            self._dispatcher.fire_framework_stopping()

            bid = self.__next_bundle_id - 1
            while bid > 0:
                bundle = self.__bundles.get(bid)
                bid -= 1

                if bundle is None or bundle.get_state() != Bundle.ACTIVE:
                    # Ignore inactive bundle
                    continue

                try:
                    bundle.stop()
                except Exception as ex:
                    # Just log exceptions
                    _logger.exception(
                        "Error stopping bundle %s: %s",
                        bundle.get_symbolic_name(),
                        ex,
                    )

            # Framework is now stopped
            self._state = Bundle.RESOLVED
            self._dispatcher.fire_bundle_event(
                BundleEvent(BundleEvent.STOPPED, self)
            )

            # All bundles have been stopped, release "wait_for_stop"
            self._fw_stop_event.set()

            # Force the registry clean up
            self._registry.clear()
            return True
Stops the framework

        :return: True if the framework stopped, False it wasn't running