Refactored quit event

Now it's not a global variable