fix SIGTERM handling before starting default_loop
Merge pull request #273 from sabottenda/fix-shutdown-handling

Fix shutdown issues