Add manual quit handling (fixes issue #153)