Why does a ruler continue to slide after toppling?
OK, since it's a quiet Friday evening in and since I'm allegedly an experimental scientist I videoed my ruler while it was falling. My phone doesn't do slow motion (it probably does and I just don't know how to work it!) so the time resolution is limited, but here are four successive frames from the video.
It should be obvious that the bottom edge of the ruler does leave the object it is resting against. I've drawn a red line on the images to show this, though I'm not sure how clear it is in these pictures. The frame rate is 30 fps, so the pictures shown cover only 0.1 seconds. I think this is too short a time for the eye to follow the motion of the bottom edge of the ruler. I could not see the bottom edge moving away when just watching the ruler fall. In fact I was a bit surprised to see it on the video.
I note that the ruler starts to move away between around 45° to 30° to the horizontal, which tallies quite nicely with Michael's estimate of 41.8°.
As noted by John Rennie in the comments, there will be a point as the ruler falls where it loses contact with the ridge and begins to slide to the right. The idea here is that if the ruler were to keep its pivot point fixed, then at some point, the force applied by the pivot point would have to switch from having a component to the right to having a component to the left (i.e., pulling the CM back in rather than pushing it out.) Since the "ledge" specified in the OP can only exert a force to the right, this will be the point that the base of the ruler begins to slide away from the ledge. (This is similar in spirit to the classic "disc slides down a frictionless hemisphere" problem.)
To prove this, we use conservation of energy to find the ruler's angular velocity as a function of $\theta$. This becomes $$ \frac{1}{2} I \omega^2 = mg \frac{h}{2} ( 1- \cos \theta) \quad \Rightarrow \quad \frac{1}{3} h^2 \omega^2 = gh (1 - \cos \theta) \quad \Rightarrow \quad \omega^2 = \frac{3g}{h}(1 - \cos \theta). $$ Taking the derivative of both sides with respect to time, we get $$ 2 \omega \alpha = \frac{3 g}{h} \sin \theta \omega \quad \Rightarrow \quad \alpha = \frac{3gh}{2} \sin \theta $$
The linear acceleration of the center of mass is therefore $$ \vec{a} = \frac{h}{2} (- \omega^2 \hat{r} + \alpha \hat{\theta}) = - \frac{3g}{2}(1 - \cos \theta) \hat{r} + \frac{3g}{4} \sin \theta \hat{\theta} $$ using polar coordinates (with $\theta = 0$ at the vertical and increasing clockwise.) In terms of the Cartesian components, we have $\hat{r} = \cos \theta \hat{y} + \sin \theta \hat{x}$ and $\hat{\theta} = \cos \theta \hat{x} - \sin \theta \hat{y}$, so all told this becomes \begin{align*} \vec{a} &= - \frac{3g}{2}(1 - \cos \theta) (\cos \theta \hat{y} + \sin \theta \hat{x}) + \frac{3g}{4} \sin \theta (\cos \theta \hat{x} - \sin \theta \hat{y}) \\ &= \frac{3g}{2}\left((\cos \theta - 1) + \frac{1}{2} \cos \theta \right) \sin \theta\hat{x} + \frac{3g}{2}\left((\cos \theta - 1) \cos \theta - \frac{1}{2} \sin^2 \theta \right) \hat{y}. \end{align*}
We see that $a_x = 0$ when $\frac{3}{2} \cos \theta - 1 = 0$, or $\cos \theta = \frac{2}{3}$, or $\theta \approx 48.2^\circ$. Thus, once the ruler falls past this angle, the net force on center of mass must be to the left to keep it moving in a circular arc. On a perfectly frictionless table, the ruler would leave the "ledge" at this point, since the ledge is unable to provide a force in this direction. In reality, friction might be able to hold the bottom of the ruler in place for a bit longer than this, making the angle at which the ruler leaves the ledge much closer to the horizontal.