Most modern semiautomatic firearms will, once the last round is fired, lock the slide, bolt, or analogous operating part open both as an indicator that the weapon is empty, and also to aid in returning to fire once a new magazine is inserted.
The slide release lever, sometimes not actually a lever but a button, switch, or toggle, will release the slide or bolt back into battery (firing position), usually chambering a round from the freshly-inserted magazine, if there is one.
A typical sequence of events is illustrated thus:
1) The trigger is pulled, dropping the hammer onto the firing pin, which strikes the primer of the chambered round.
2)The bullet exits the barrel, and the force of recoil or siphoned gas pressure from powder detonation operates the weapon - the empty brass case is ejected
3) Since there are no more bullets in the magazine, the slide or bolt catches on the magazine follower and is delayed in its forward progress; the slide release lever then holds the slide or bolt open.
4) The operator releases the empty magazine, and inserts a new one
5) The operator presses the slide release lever, which allows the slide or bolt to move forward, stripping the top round off of the new magazine and putting it into the chamber
6) The weapon is now ready to fire again. From the weapon's point of view, this sequence of actions is no different than if the magazine had not run out of bullets.