Perching a router on a shelf edge to flush-trim solid-wood edges can turn ugly if your machine tips. Give it stability by clamping together the shelves on edge. Cut spacer blocks from 2x4 scrap and place them between the shelves at both ends. Then clamp the spacers and shelves together. (We clamped one of those clamps to the bench for added stability.) Then rout each edge with a flush-trim bit. If the router wobbles on the edges of the outside shelves, move those pieces to the inside, reclamp, and finish routing.