write quit function