Block a road for OpenStreetMap directions maker

Yes, this is the right way to block traffic. Simply drawing a fence across a road (whether connected by a node or not) is just drawing a fence (similarly with barrier=gate). Somewhere there needs to be explicit access tags blocking access.