Add the graceful shutdown to API.
Merge pull request #16 from vogdb/issue-16

Handle daemon shutdown