add function end() and force_end() and test case for function end(), fix bug in start() casuing infinite loop