def check_end_process(current_process, stock, key):
    """
    Check if process ended
    if so, adding it's output to the stock and setting busy to false.
    """
    current_process.delta_time += 1
    if (current_process.delta_time is current_process.time):
        for key, output in current_process.output.items():
            print("Creating {} {}".format(output, key))
            current_process.requested -= output
            stock[key] = stock[key] + output if key in stock else output
        current_process.delta_time = 0
        current_process.busy       = False
        print("Process {} ended".format(key))
    return current_process, stock