add shutdown script

code extracted from fresh_start.sh
closes #612