Adding code to terminate pasting if an error is encountered.

Refs #1839
Merge branch 'bugfix/1839_fix_cut_copy_commands_in_script_interpreter' into develop