Yes. You can close your position at any time during market hours before the expiry date by selling the option. You do not have to hold it until expiry.
Selling early is often a good idea if the stock has moved significantly in your direction, because the option may still have time value that you would lose by waiting until expiry.