Added a reset function to clean up main and quit