### Description

This applies to the following APIs:
- [x] open anomaly detection
- [x] start datafeed
- [x] start data frame analytics job
- [x] start trained model deployment

Currently, if the operation takes longer than the configured `timeout`, the response status code is `500`.

With Kibana in mind, a `4xx` response would be more suitable as it will lead to showing more useful information to the user about why the request failed.

Looking at [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-408-request-timeout), it seems the most appropriate `4xx` code would be `408 Request Timeout`, even though the RFC describes a different situation. 

The alternative, `504 Gateway Timeout`, would be more appropriate for this situation but it wouldn't improve the user experience in Kibana.
x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java
String jobId = "realtime-close-job";
        String datafeedId = jobId + "-datafeed";
        startRealtime(jobId);
        try {
            CloseJobAction.Response closeJobResponse = closeJob(jobId);
            assertTrue(closeJobResponse.isClosed());
        } catch (Exception e) {
            NodesHotThreadsResponse nodesHotThreadsResponse = client().admin().cluster().prepareNodesHotThreads().get();
            int i = 0;
            for (NodeHotThreads nodeHotThreads : nodesHotThreadsResponse.getNodes()) {
                logger.info(i++ + ":\n" + nodeHotThreads.getHotThreads());
            }
            throw e;
        }
        assertBusy(() -> {
            GetDatafeedsStatsAction.Request request = new GetDatafeedsStatsAction.Request(datafeedId);
            GetDatafeedsStatsAction.Response response = client().execute(GetDatafeedsStatsAction.INSTANCE, request).actionGet();
            assertThat(response.getResponse().results().get(0).getDatafeedState(), equalTo(DatafeedState.STOPPED));
        });
    }
    public void testCloseJobStopsLookbackOnlyDatafeed() throws Exception {
        String jobId = "lookback-close-job";
        String datafeedId = jobId + "-datafeed";
        boolean useForce = randomBoolean();
        client().admin().indices().prepareCreate("data").setMapping("time", "type=date").get();
        long numDocs = randomIntBetween(1024, 2048);
        long now = System.currentTimeMillis();
        long oneWeekAgo = now - 604800000;
        long twoWeeksAgo = oneWeekAgo - 604800000;
        indexDocs(logger, "data", numDocs, twoWeeksAgo, oneWeekAgo);