@bash.close created error when the streams were already closed before error handling. Error fixed by adding 'if  @bash.ready?'