First of all, it is a bad idea to transform the image for cropping. It will results in changing the content of the ROI with artifacts due to interpolation when applying the homography. In addition, if one day you want to turn into a ROI defined by more than 4 points, this approach doesn't apply anylonger.
Second, I make some minor changes to your script, like this:
img = imread('circuit.tif');
imshow(img);
h = impoly;
position = wait(h);
boundbox = [min(position(:,1)), ....
min(position(:,2)), ....
max(position(:,1))-min(position(:,1)), ....
max(position(:,2))-min(position(:,2))];
BW = createMask(h);
img = imcrop(uint8(BW).*img, boundbox);
imshow(img)
You were almost there ... just mask the ROI of the image you want and crop with the bounding box of the ROI. Here it puts 0 outside the mask; you can adapt differently if you want.