To make sure it is correct you can execute: $ cardano-cli query utxo --address $(cat $NODE_HOME/payment.addr) --mainnet
and that should display the same UTXOs as what is in ${tx_in}.
Additionally to clarify ${currentSlot}.
When building the raw transaction you calculate the current slot, and according to the tutorial you add 10000 seconds, as in: --invalid-hereafter $(( ${currentSlot} + 10000)) \
So you need to make sure you try to submit the transaction within those 10000 seconds.
Try again the whole procedure sending a small transaction. Check if ${tx_in} is correct as described above and make sure you try to submit the transaction
The 500 ADA won’t be lost. They will be transferred back to your original stake address. So make sure you don’t unregister it. Collect your ADA then do whatever you want later.