Properly shutdown to resolve #3