Proper quit handling
Some fixs