Whenever a new order is created, it is compared against open orders in the order book starting from the best price. If the best price is compatible with the new order's limit price, a trade takes place at the best price. If there are multiple orders at the same price, they are prioritised by the time that they were submitted. This is repeated until no more trades are possible. The new order is then entered into the order book itself. If an order is stopped, it is removed from the order book.
An order may end up in one of three states:
Filled: The order was completely matched.
Unfilled: The order was unable to trade at all by the time it was stopped.
Partially filled: The order caused some trades but still had capacity left over when it was stopped.