Fix --timeout argument to work with directories

The --timeout argument was working with individual files, but when scanning a directory it wasn't measuring the time spent on scanning the directory as a whole.