Don't disconnect when running tasks inline

This fixes issues in production and testing environments.