Correctly shutdown when ctrl+c is pressed.