Close database variable in route