Fix signal handling when running script.