Wait for tasks to finish before shutting down
Shutdown tasks before logout, fixes #297
Merge branch 'master' into builds
7.251