Technically, all officers serve "at the pleasure of the President." So you can offer your resignation, but if the President refuses to accept it, you can't just quit anyway. And in this case, Trump refuse to accept Milley's resignation.
I despise Milley, but he's still in office because Trump refused to accept his resignation, not because he was unwilling to resign.