Raise an error when the session is required and the device is closed (session is None)

See #75