In manually operated firearms, such as bolt-action, lever-action, and pump-action rifles and shotguns, the bolt is held fixed by its locking lugs during firing, forcing all the expanding gas forward, and is manually withdrawn to chamber another round.
In an automatic or semi-automatic firearm, the bolt cycles back and forward between each shot, propelled by recoil or expanding gas (back) or the recoil spring (forward). When it moves back, the extractor pulls the spent casing from the chamber. When it moves forward, it strips a cartridge from the magazine and pushes it into the chamber. Once the case is clear of the chamber, the ejector kicks the case out of the firearm.
In a closed bolt firearm, the bolt is in its foremost position upon firing. This is opposed to an open bolt firearm where the bolt is held rearward and pulling the trigger releases it to slam forward and fire the cartridge.