Properly finalizing DB statements