Is there a command to drop all temp tables when re-running the query?

This answer that was already given to you by @robert_volk should help guide you. Also read the documentation of temp tables