Fixed quit function