diff --git a/lib/winrm/shells/power_shell.rb b/lib/winrm/shells/power_shell.rb index d9ca50d2..f2aba67d 100644 --- a/lib/winrm/shells/power_shell.rb +++ b/lib/winrm/shells/power_shell.rb @@ -34,6 +34,9 @@ def finalize(connection_opts, transport, shell_id) end def close_shell(connection_opts, transport, shell_id) + return false unless Thread.current.alive? + + Thread.current.wakeup if Thread.current.status =~ /sleep/ msg = WinRM::WSMV::CloseShell.new( connection_opts, shell_id: shell_id,