once something starts burning, how does it stop itself from burning?
Certain materials are said to be self-extinguishing when they will not sustain combustion by themselves, once an external source of flame has been removed.
An example would be a material commonly used for printed circuit boards, known as FR-4, which basically is glass reinforced epoxy containing certain additives, usually bromine-based (and environmentally slightly nasty).
See also:
Flame Retardant (WP) for information on the exact mechanisms involved.