Prevent "window belongs to another process" errors when running