Do SSL cleanups on exit

So that there are fewer issues with valgrind