Carefully handle the signal, exit gracefully