Yes, you can withdraw when you still have an open position.
You will need to take extreme care in such scenarios. After all, withdrawals from an account with open positions may trigger a margin call or automatic stop out on your account. Thus, managing your risk and margin levels remain your responsibility, and we cannot restore any closed positions