rewrite shutdown mechanism
merge