desert a sinking ship

desert /leave a sinking ship
(abandon a failing enterprise before it is too late) — бежать с тонущего корабля; покидать тонущий корабль
abandon ship
(like rats) deserting / leaving a sinking ship — как крысы с тонущего корабля

Just as sailors and rats abandon and leave a sinking ship, so we may say that a person is about to abandon a business or a cause when there is no hope of success.

Example 1: After seeing the company's financial statement, he knew it was time to desert a sinking ship.(answers.com)

Example 2: Come on you guys, don’t abandon ship on me now, just because we are meeting a few difficulties

======
This metaphoric expression alludes to rats, which leave a vessel when it founders in a storm or runs aground so as to escape drowning. It was transferred to human behavior by about 1600. (answers.com)

cf.:
jump ship
[jump on the bandwagon]