Here is a code which can be saved as a script file in the Scripts Folder.

To execute the script, drage and drop the script on the current chart, this will close all open trades and also pending orders of all symbols.