def stop(self, ends=None, forced=False):
if self._started.isSet():<EOL><INDENT>if ends:<EOL><INDENT>self._stopping.set()<EOL>log.debug('<STR_LIT>' % self)<EOL>to_do = ends[:] <EOL>while to_do:<EOL><INDENT>for task in to_do:<EOL><INDENT>try:<EOL><INDENT>self.next(task=task)<EOL><DEDENT>except StopIteration:<EOL><INDENT>to_do.remove(task)<EOL>log.debug('<STR_LIT>' % (self, task))<EOL>continue<EOL><DEDENT>except Exception as excp:<EOL><INDENT>log.debug('<STR_LIT>' %(self, task, excp))<EOL><DEDENT><DEDENT><DEDENT>self._stop()<EOL>log.debug('<STR_LIT>' % self)<EOL><DEDENT>elif forced:<EOL><INDENT>self._stopping.set()<EOL>log.debug('<STR_LIT>' % self)<EOL><DEDENT>else:<EOL><INDENT>msg = '<STR_LIT>' %self<EOL>log.error(msg)<EOL>raise RuntimeError(msg)<EOL><DEDENT><DEDENT>
Stops an ``NuMap`` instance. If the list of end tasks is specified *via*
the "ends" argument a call to ``NuMap.stop`` will block the calling 
thread and retrieve (discards) a maximum of 2 * stride of results. This 
will stop  the worker pool and the threads which manage its input and 
output queues respectively. 

If the "ends" argument is not specified, but the "forced" argument is 
the method does not block and the ``NuMap._stop`` has to be called after
**all** pending results have been retrieved. Calling ``NuMap._stop`` with
pending results **will** dead-lock.

Either "ends" or "forced" has to be ``True``.

Arguments:

  - ends (``list``) [default: ``None``] A list of task ids which are not
    consumed within the ``NuMap`` instance.
  - forced (``bool``) [default: ``False``] If "ends" is not ``None`` 
    this argument is ignored. If "ends" is ``None`` and "forced" is 
    ``True`` the ``NuMap`` instance will trigger *stopping mode*.