Come da manuale, inserisci exit(); dopo ogni chiamata header location.