Fix exception when trying to clear empty history

If history has already been cleared, a subsequent attempt to do so throws an exception because the directory does not exist.