It's not against the law. But it is a violation of the contract of carriage you entered into when you bought your ticket. Many people do this. It's called “Hidden City Ticketing” and it's a practice that should be used lightly because the airline will just ban you in the future if you do this too much.