Create a separate function to delete directories.

Helps reuse some code.