Improve a little bit on how the script stops