I believe the most common way to block the player is to add a "wall" around your tile map.
Either as an actual wall tile that blocks the player and is around the entire map, think Zelda where there are trees or mountains covering the entire side of the map.
Or an invisible wall which is basically a StaticObject2D without a sprite that simply does not let the player through, like GTA for example.