Close off database transactions promptly
Merge pull request #64 from Rosuav/transactions

Close off database transactions promptly