Adds signal handling for clean exit