Closes DigiDocService session and clears request.session[I{DIGIDOC_SESSION_KEY}]

def destroy_digidoc_session(self):
        """ Closes DigiDocService session and clears request.session[I{DIGIDOC_SESSION_KEY}]
        """

        # cleanup data too
        self.destroy_digidoc_session_data()

        try:
            session = self.request.session[self.DIGIDOC_SESSION_KEY]

            if session:
                try:
                    service = self.flat_service()
                    service.session_code = session
                    service.close_session()

                except DigiDocError:
                    pass

            del self.request.session[self.DIGIDOC_SESSION_KEY]

        except KeyError:
            pass