It was likely dark humor, however a commanding officer can "fire" a subordinate officer by permanately releaving them of their duties and replacing they with a new officer.They're the C.O. and chief engineer of a military starship, not a civilian employee and his boss.
Scott would go into Starfleet's "labor pool,' and await a new assignment. Any prospective new commanding officer would take into account the he was releaved with prejudice from him last posting.
Again probably just dark humor.
