Fixed db() session closing bug