In ruby the method body can’t access local variables accessed outside of it. Multiple methods can have the same locsal variables names without collisions. If you want to actually point to the same variable you need to use class variables (or class instance variables).
In this case however I think I’d call GetActiveWindow inside the method instead of using a variable since the active window may not have been SketchUp while the firtst code ran (users can switch focus to another window, e.g. to check their mail, while SU starts up).
Also I would recommend you to read a Ruby style guide as your code is often quite hard to read. In Ruby snake_case is used for variables and method names. Using CamelCase makes it appear as a constant, even if the first character is lower case. Also semicolon is redundant and distracting in Ruby.
extend self # creates both class and module methods
# module constant
HELLO = 'Hello from Barra' unless defined?( HELLO )
# use the constant in any method in your namespace
UI.messagebox( HELLO )
end # say_hi
# Usage from outside of code
# use the method
# or use the constant
# UI.messagebox( Bara::HELLO )
Take a look at other plugins (there exists already a lot of source code) to learn Ruby and to learn best practices.
Both modules and classes are containers for code (namespaces). You must use one of them to keep your code separate from other plugins. Classes are modules that can be instantiated. If it does not make sense to instantiate something (because there exists only one of that kind), use a module. See John’s answer.
Everything that is not needed anymore is automatically removed from memory. That is also true for instances. Something is not anymore used if there exists no variable referencing it. Learn what scope is: scope is the region of a program where a variable name is valid. Different variable types have different scope. Example:
# No reference → instance can be removed from memory
# Local variable → lives only until the end of the current method; or outside of methods until the end of the scope/script.
my_instance = MyClass.new()
# Module variable → lives permanently in the scope of the module.
# Because of this, you must ensure it always has a valid value.
# For example don't set it to nil when another part of the program assumes it is not nil.
@module_variable = 42
@module_variable = value
# It still exists here!