Modified UI classes to end the db session before exiting