With all his riches, Mahmud founded a university, a library, and a museum, a grand mosque and richened his capital. When Mahmud was about to die, he ordered all of his riches to be placed before him. Mahmud died on 30 April 1030.