You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: session.rb
    path of file: ./repos/metasploit-framework/lib/msf/core
    
    the code of the file until where you have to start completion: # -*- coding: 
    
  def cleanup
    if db_record and framework.db.active
      ::ApplicationRecord.connection_pool.with_connection do
        framework.db.update_session(id: db_record.id, closed_at: Time.now.utc, close_reason: db_record.close_reason)
      rescue ActiveRecord::RecordNotFound
        nil  # this will fail if the workspace was deleted before the session was closed, see #18561
      end
    end