Edited quit function