If you want to prevent the IB TWS shutting down every night, you can achieve this by activating the Auto Restart feature in the Lock and Exit settings in the global configuration.
The following example shows restarting at 6 pm US Eastern Time automatically, assuming the machine runs on US Eastern Time timezone.
This will keep the user logged in for 1 week and just restarting every day automatically.
Further information on this Auto Restart feature can be found at IB: https://www.ibkrguides.com/tws/usersguidebook/configuretws/auto_restart_info.htm
Note: OptraBot will automatically reconnect to TWS again after it has restarted itself.