fixed leak of method when ctx malloc fails; implemented get_shutdown