Add timer_deinit and call it just before doing a soft-restart

This fixes #733.