Fix daemon graceful exiting