Moved the clear action to the place before exiting scheduler