Not allowed under cabotage, so you shouldn't be able to book it as one ticket. You'd have to go out through Canadian customs/immigration and back in through US customs/immigration, which will take longer than 40 minutes... so, not likely to work on a number of levels.