Make sure to shutdown connections before exiting
Fixes segfault on exit