Fixing bug where prepared statements were not being closed.