The exact details will depend on airline policy and national law, but in general, airlines would prefer you make up your mind before boarding.
Once the aircraft door is closed, you're generally committed. If there are lengthy delays of several hours, airlines in the United States are required to give you an opportunity to eventually get off the plane when it is safe to do so (subject to various exceptions). Beyond that, if you make enough of a fuss, the airline may have you removed because they consider you an "unruly passenger" and feel unsafe flying with you, but that's not a position you want to find yourself in (you could find yourself talking to the police or under arrest).
Before the door is closed, you have more options. If you have checked luggage, the airline may be required to remove your bags if you're not flying, which could delay the flight for everyone else. In some cases, they may also fly on with your bags, and it could be some time before you see them again. Without checked bags, you can generally get off before the door is closed, but you may have to pay a change fee to get on another flight or forfeit the value of your ticket.
All airline tickets are governed by your contract with the airline, normally spelled out in the conditions of carriage somewhere on the airline's website. Most are non-refundable. If the ticket is refundable and permits refunds even after boarding, you could request a refund according to the contract. Otherwise, you won't receive a refund, but may be able to change to a later flight with the same airline (after paying any applicable change fees).