def pop_task(tasks, task_id):
    """Remove task with given identifier and return the task handle. The result
    is None if no task with the given identifier exists.

    Parameters
    ----------
    tasks: dict(vizier.engine.base.ExtendedTaskHandle)
        Dictionary of task handles
    task_id: string
        Unique task identifier

    Returns
    -------
    vizier.engine.base.ExtendedTaskHandle
    """
    if not task_id in tasks:
        return None
    task = tasks[task_id]
    del tasks[task_id]
    return task
