        def close(self, restore=True):
            """
            Close down this Screen and tidy up the environment as required.

            :param restore: whether to restore the environment or not.
            """
            self._signal_state.restore()
            if restore:
                self._screen.keypad(0)
                curses.echo()
                # Shouldn't fail on real systems.  This code is for running tests in CI pipelines.
                try:
                    curses.nocbreak()
                except curses.error:
                    pass
                try:
                    curses.endwin()
                except curses.error:
                    pass
Close down this Screen and tidy up the environment as required.

:param restore: whether to restore the environment or not.
asciimatics/screen.py