Bug fix: Closing connection to the database