Changed listener slightly and allowed app to quit gracefully@