Dont allow connection to be closed multiple times

Fixes crash when using transactions