mllib: add an hook to cleanup directories on exit

Much similar to unlink_on_exit, but recursively cleaning directories.