Fix "unable to close due to unfinalized statements" error.