 By December 1002 Khalaf was forced to surrender.He was sent to Farighunid Guzgan, where he lived until 1006 or 1007.Rumors that Khalaf was in contact with the Karakhanids, whom Mahmud was at war with at the time, resulted in him being transferred south to Gardez, where he died in 1009.