Correctly terminating the timer