Predicting when a patient with advanced cancer is dying is a challenge and currently no prognostic test is available. We hypothesised that a dying process from cancer is associated with metabolic changes and specifically with changes in volatile organic compounds (VOCs). We analysed urine from patients with lung cancer in the last weeks of life by headspace gas chromatography mass spectrometry. Urine was acidified or alkalinised before analysis. VOC changes in the last weeks of life were identified using univariate, multivariate and linear regression analysis; 12 VOCs increased (11 from the acid dataset, 2 from the alkali dataset) and 25 VOCs decreased (23 from the acid dataset and 3 from the alkali dataset). A Cox Lasso prediction model using 8 VOCs predicted dying with an AUC of 0.77, 0.78 and 0.85 at 30, 20 and 10 days and stratified patients into a low (median 10 days), medium (median 50 days) or high risk of survival. Our data supports the hypothesis there are specific metabolic changes associated with the dying. The VOCs identified are potential biomarkers of dying in lung cancer and could be used as a tool to provide additional prognostic information to inform expert clinician judgement and subsequent decision making.