This has been done a time or two.
Your method works fine for deleting all global variables, but people frequently have some they absolutely DON'T want to delete.
This macro shows how to exclude variables by name and by partial-name from those deleted.
Delete All Variables Except… - #3 by ccstone
You could do something similar with your macro if desired.
You can also open the Keyboard Maestro Editor preferences to the variables panel, select-all (or some) and hit the Delete key.
-Chris