What happens if you get liquidated? Do you have to pay the loan back? Can you get an example?

Answer

If your position for margin is liquidated, it is forced to close the position to pay the loan back. You wont get charged more than your initial margin, means you wont be in debt for using the margin.