Clean up connections on errors