---
title: "stopRecording(withOutput:completionHandler:)"
framework: replaykit
role: symbol
role_heading: Instance Method
path: "replaykit/rpscreenrecorder/stoprecording(withoutput:completionhandler:)"
---

# stopRecording(withOutput:completionHandler:)

Stops the current recording and writes the movie to the specified output URL.

## Declaration

```swift
func stopRecording(withOutput url: URL, completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

```swift
func stopRecording(withOutput url: URL) async throws
```

## Parameters

- `url`: The output URL.
- `completionHandler`: The completion handler the system calls when the movie is written to the specified output URL. If an error occured, the system passes the completion handler an doc://com.apple.documentation/documentation/Foundation/NSError that indicates the reason the operation failed.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func stopRecording(withOutput url: URL) async throws For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Controlling App Recording

- [startRecording(handler:)](replaykit/rpscreenrecorder/startrecording(handler:).md)
- [stopRecording(handler:)](replaykit/rpscreenrecorder/stoprecording(handler:).md)
- [startCapture(handler:completionHandler:)](replaykit/rpscreenrecorder/startcapture(handler:completionhandler:).md)
- [RPSampleBufferType](replaykit/rpsamplebuffertype.md)
- [stopCapture(handler:)](replaykit/rpscreenrecorder/stopcapture(handler:).md)
- [discardRecording(handler:)](replaykit/rpscreenrecorder/discardrecording(handler:).md)
- [startRecording(withMicrophoneEnabled:handler:)](replaykit/rpscreenrecorder/startrecording(withmicrophoneenabled:handler:).md)
