Properly terminating before restart