If you run it in a browser (as Javascript or Wasm), then it won't be able to run system commands like deleting files. Browsers take care of that, or it'd be massively unsafe. In general you can make interpreters unable to execute system commands by not exposing them (and making sure you have no security bugs).
A normal programming language is Turing-complete. And it's a famous law of Turing-complete languages that you can't predict whether they will terminate. So you can't do that, although usually browsers will terminate scripts that are unresponsive for too long.