Completed quit() function