If you cease to work for the first employer (either you quit or they fire you), the visa is cancelled.
There's no such thing as an H1B "transfer", but the new employer can apply for a new H1B visa. The good news is that you don't have to requalify for the cap the second time around.