Does waiting a moment and clicking Retry also work, or do you keep seeing the same error?
Is the folder actually empty, or are there still things left in it? (Check for hidden/system files as well. If using Opus, you can click the hidden count on the status bar to disable all filtering and show everything.)
(A file delete can succeed but leave the file still there in a "pending delete" state until something else which has the file open closes it. It's rare but would be a legitimate cause of that error message. Happens most often with video files, in my experience, due to the way some video components open them. You should still see the file in the directory in that case, though.)
From a quick search, it seems to be a problem a few people have run into on Windows 10 with various tools (most part of the OS itself), but isn't something I've heard about before: windows - How to solve "The directory is not empty" error when running rmdir command in a batch script? - Stack Overflow
If it only happens on a NAS then it could be the NAS doing something unusual on its side, but if it also happens on local drives and the folders really are empty then it's unexpected. Antivirus or similar tools could be involved, perhaps, as they can modify the way the filesystem APIs behave.
A Process Monitor log of what happens might reveal some more details.