This is a fairly standard communication question. One approach would be to use a ResultReceiver in Activity A:
Intent GotoB=new Intent(A.this,B.class);
GotoB.putExtra("finisher", new ResultReceiver(null) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
A.this.finish();
}
});
startActivityForResult(GotoB,1);
and then in Activity B you can just finish it on demand like so:
((ResultReceiver)getIntent().getExtra("finisher")).send(1, new Bundle());
Try something like that.