finish the main program