Gosh, I got it wrong then? (After retrying) … no I did not. Almost not, that is.
First of all, if you copied my line from the post, make sure the three dots are actually three dots. The forum software translated them in an ellipsis. With that out of the way, let's experiment.
Does it work? No. Why not? There are no “unused styles” in my test document.
Next try, with an added style. Does it work? No. Why not? The first line on its own does select this one style, but the “Delete styles…” command fails. Why? When there is only one style selected, the menu actually reads “Delete Style…” — singular. Changing the 2nd line to this exact text makes it — finally — work as expected; and so does adding one more unused style and using the original lines.
Can you “count” how many styles are selected after the first line? No. Only thing left is to wrap this line into a try … catch statement, and if one fails, try the other (and that may fail as well, if there are no unused styles or — insiduously — your Basic Paragraph Syles is “unused”). So the, uh, (I was going to say “best”!) least worse solution could be something like
1. make sure Basic Paragraph is used. Create a text frame and apply this style; delete it when done.
2. add not one but two new paragraph styles. Make sure one is not “based on” the other, because that will count as “being used”.
3. invoke “select unused”
4. invoke “delete styles …” — using the plural ought to be safe.
Lesson learned: better not try to use “menu invoke”! A quick google lead me to this thread-from-the-past, but the general idea ought still work for CS4, 5, 6 and beyond: https://forums.adobe.com/thread/500399