Fix the root output directory when cleaning examples

This forgot to take into account the logic from some other locations, so I added
a helper method!

Closes #912