fix #43 add null check to shutdown