Finish quit function